<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="generator" content="VuePress 2.0.0-beta.60">
    <script>
      (function() {
        const userMode = localStorage.getItem('vuepress-reco-color-scheme') || 'auto';
        const systemDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;

        if (userMode === 'dark' || (userMode === 'auto' && systemDarkMode)) {
          document.documentElement.classList.toggle('dark', true);
        }
      })();
    </script>
    <title>Java 代码生成器 | 阿派 | Apai Blog</title><meta name="description" content="Just playing around">
    <link rel="modulepreload" href="/assets/app-8a43a0f0.js"><link rel="modulepreload" href="/assets/framework-e1bed10d.js"><link rel="modulepreload" href="/assets/DmShengChen.html-92a2db1f.js"><link rel="modulepreload" href="/assets/DmShengChen.html-bb069d8e.js"><link rel="prefetch" href="/assets/index.html-ef2f4f01.js" as="script"><link rel="prefetch" href="/assets/index.html-1013d654.js" as="script"><link rel="prefetch" href="/assets/index.html-a146dedc.js" as="script"><link rel="prefetch" href="/assets/index.html-f4b2eaea.js" as="script"><link rel="prefetch" href="/assets/index.html-e3ed352e.js" as="script"><link rel="prefetch" href="/assets/index.html-42ce2ab9.js" as="script"><link rel="prefetch" href="/assets/index.html-ec24ec9e.js" as="script"><link rel="prefetch" href="/assets/index.html-d3d8d7ce.js" as="script"><link rel="prefetch" href="/assets/index.html-9faf073b.js" as="script"><link rel="prefetch" href="/assets/index.html-9364b7dd.js" as="script"><link rel="prefetch" href="/assets/index.html-fc0fb462.js" as="script"><link rel="prefetch" href="/assets/index.html-603c6c19.js" as="script"><link rel="prefetch" href="/assets/index.html-0349deb8.js" as="script"><link rel="prefetch" href="/assets/index.html-09405a87.js" as="script"><link rel="prefetch" href="/assets/index.html-91577c59.js" as="script"><link rel="prefetch" href="/assets/index.html-552ae255.js" as="script"><link rel="prefetch" href="/assets/index.html-424369c4.js" as="script"><link rel="prefetch" href="/assets/index.html-1dfc0069.js" as="script"><link rel="prefetch" href="/assets/index.html-ec62f595.js" as="script"><link rel="prefetch" href="/assets/index.html-4621ef22.js" as="script"><link rel="prefetch" href="/assets/index.html-e189ec13.js" as="script"><link rel="prefetch" href="/assets/index.html-b424a45b.js" as="script"><link rel="prefetch" href="/assets/index.html-623952a8.js" as="script"><link rel="prefetch" href="/assets/index.html-cedcb7c8.js" as="script"><link rel="prefetch" href="/assets/index.html-07f61d2f.js" as="script"><link rel="prefetch" href="/assets/index.html-9ef01f1e.js" as="script"><link rel="prefetch" href="/assets/index.html-dfa6d19f.js" as="script"><link rel="prefetch" href="/assets/index.html-23dd0955.js" as="script"><link rel="prefetch" href="/assets/index.html-1e7a4ff3.js" as="script"><link rel="prefetch" href="/assets/index.html-e12f154a.js" as="script"><link rel="prefetch" href="/assets/index.html-30de2d02.js" as="script"><link rel="prefetch" href="/assets/index.html-6a244983.js" as="script"><link rel="prefetch" href="/assets/index.html-8900b10e.js" as="script"><link rel="prefetch" href="/assets/index.html-b3210461.js" as="script"><link rel="prefetch" href="/assets/biaoqian-fenlei-moban.html-2db9524d.js" as="script"><link rel="prefetch" href="/assets/MuBan-Apai.html-5af383c8.js" as="script"><link rel="prefetch" href="/assets/guide.html-5aaed80e.js" as="script"><link rel="prefetch" href="/assets/Lu-aboutMe.html-82ee5401.js" as="script"><link rel="prefetch" href="/assets/kaishi.html-9d8493a0.js" as="script"><link rel="prefetch" href="/assets/Hobby-SheYing.html-3ac28a1b.js" as="script"><link rel="prefetch" href="/assets/Lu-aboutMe.html-96d10c31.js" as="script"><link rel="prefetch" href="/assets/Work-MaYun.html-5e497e8c.js" as="script"><link rel="prefetch" href="/assets/Java-basics.html-4a44925e.js" as="script"><link rel="prefetch" href="/assets/JavaAPI.html-ae8a1843.js" as="script"><link rel="prefetch" href="/assets/JavaBiKeng04.html-c9e75b16.js" as="script"><link rel="prefetch" href="/assets/JavaGongNeng03.html-6ca97faf.js" as="script"><link rel="prefetch" href="/assets/JavaJinJie02.html-eaabb81d.js" as="script"><link rel="prefetch" href="/assets/JavaMyUtil.html-e2cff404.js" as="script"><link rel="prefetch" href="/assets/MyBatisPlus.html-b608a85b.js" as="script"><link rel="prefetch" href="/assets/MySql.html-4bcdc408.js" as="script"><link rel="prefetch" href="/assets/MySqlFunction.html-23affe6f.js" as="script"><link rel="prefetch" href="/assets/RabbitMQ.html-2cc19b22.js" as="script"><link rel="prefetch" href="/assets/Redis.html-f7a014e9.js" as="script"><link rel="prefetch" href="/assets/ShiWuAffair.html-33f5c0c4.js" as="script"><link rel="prefetch" href="/assets/Spring.html-628746d6.js" as="script"><link rel="prefetch" href="/assets/SpringConfig.html-49f3c621.js" as="script"><link rel="prefetch" href="/assets/SpringPeiZhi.html-ac6df88a.js" as="script"><link rel="prefetch" href="/assets/SpringSecurity.html-057633f1.js" as="script"><link rel="prefetch" href="/assets/WebSocket.html-57d6fc97.js" as="script"><link rel="prefetch" href="/assets/DockerCompose.html-98ad6b52.js" as="script"><link rel="prefetch" href="/assets/Linux.html-43351365.js" as="script"><link rel="prefetch" href="/assets/Nginx.html-f1276de6.js" as="script"><link rel="prefetch" href="/assets/RabbitMQ_COPY.html-5cdb6370.js" as="script"><link rel="prefetch" href="/assets/Redis_COPY.html-486e1d26.js" as="script"><link rel="prefetch" href="/assets/Redis_CRUD.html-47e0af0f.js" as="script"><link rel="prefetch" href="/assets/BatJiaoBen.html-d2d2666a.js" as="script"><link rel="prefetch" href="/assets/EasyExcel.html-b1eb613d.js" as="script"><link rel="prefetch" href="/assets/GitLu.html-eae89aa5.js" as="script"><link rel="prefetch" href="/assets/JavaKaiFa.html-4fbb86cc.js" as="script"><link rel="prefetch" href="/assets/JSR303.html-b976b418.js" as="script"><link rel="prefetch" href="/assets/MinIO.html-5e3d4702.js" as="script"><link rel="prefetch" href="/assets/ShardingJDBC.html-d0f811b3.js" as="script"><link rel="prefetch" href="/assets/Swagger.html-bb111a21.js" as="script"><link rel="prefetch" href="/assets/Vuepress.html-994cf672.js" as="script"><link rel="prefetch" href="/assets/Angular.html-3115afab.js" as="script"><link rel="prefetch" href="/assets/ElementUI.html-35bc6477.js" as="script"><link rel="prefetch" href="/assets/Html-Js.html-015f1806.js" as="script"><link rel="prefetch" href="/assets/Vue-basics.html-a64846f4.js" as="script"><link rel="prefetch" href="/assets/Vue3_group.html-f53be77f.js" as="script"><link rel="prefetch" href="/assets/Vue3_option.html-19f76b9e.js" as="script"><link rel="prefetch" href="/assets/ApifoxAPIceshi.html-19cd8153.js" as="script"><link rel="prefetch" href="/assets/PDManeryuanshujianmo.html-f6fa9d9e.js" as="script"><link rel="prefetch" href="/assets/OCRwenzishibie.html-11fc474d.js" as="script"><link rel="prefetch" href="/assets/EasyExcelbiaogeku.html-30777927.js" as="script"><link rel="prefetch" href="/assets/Javadaimashengchengqi.html-cf566ce0.js" as="script"><link rel="prefetch" href="/assets/JDKshuangbanben.html-1f259d3b.js" as="script"><link rel="prefetch" href="/assets/JSR303canshuxiaoyan.html-78322130.js" as="script"><link rel="prefetch" href="/assets/Mail  youjian.html-7e3a0f69.js" as="script"><link rel="prefetch" href="/assets/MyBatisPlusxiangjie.html-0168c152.js" as="script"><link rel="prefetch" href="/assets/MySQLzhucongfuzhi.html-7a4739e8.js" as="script"><link rel="prefetch" href="/assets/Redis-API.html-f488940c.js" as="script"><link rel="prefetch" href="/assets/SpringBootshiwu.html-c07a3864.js" as="script"><link rel="prefetch" href="/assets/SpringBootduxiefenli.html-f0993780.js" as="script"><link rel="prefetch" href="/assets/Springguolvqihelanjieqi.html-78feb321.js" as="script"><link rel="prefetch" href="/assets/WebSocket.html-caecf367.js" as="script"><link rel="prefetch" href="/assets/quanjuyichang-JSR303.html-add01eff.js" as="script"><link rel="prefetch" href="/assets/Docker.html-14746447.js" as="script"><link rel="prefetch" href="/assets/Dockeryuanchengfangwenbushu.html-7dc4f8d3.js" as="script"><link rel="prefetch" href="/assets/Nginxfanxiangdaili.html-42533685.js" as="script"><link rel="prefetch" href="/assets/Apai-SheYingOne.html-143bc574.js" as="script"><link rel="prefetch" href="/assets/Apai-Year.html-b713587f.js" as="script"><link rel="prefetch" href="/assets/My2305.html-b224c5e2.js" as="script"><link rel="prefetch" href="/assets/My2306.html-94838726.js" as="script"><link rel="prefetch" href="/assets/My2307.html-df2118c4.js" as="script"><link rel="prefetch" href="/assets/My2308.html-396c79bc.js" as="script"><link rel="prefetch" href="/assets/My2309.html-1ebdc4bb.js" as="script"><link rel="prefetch" href="/assets/My2310.html-d4ffbd04.js" as="script"><link rel="prefetch" href="/assets/My2311.html-30f23133.js" as="script"><link rel="prefetch" href="/assets/My2312.html-2da62191.js" as="script"><link rel="prefetch" href="/assets/Yi-HuBei.html-90d02bf7.js" as="script"><link rel="prefetch" href="/assets/Yi-ZhuHai.html-e202f6fb.js" as="script"><link rel="prefetch" href="/assets/Apache ECharts tubiao.html-6d4a4703.js" as="script"><link rel="prefetch" href="/assets/Vue3 zuheshi API.html-9fe2887f.js" as="script"><link rel="prefetch" href="/assets/Vue3 xuanxiangshi API.html-d584c181.js" as="script"><link rel="prefetch" href="/assets/Vue3-i18n-guojihuachajian.html-16f6e650.js" as="script"><link rel="prefetch" href="/assets/Batpichulijiaoben.html-307223b0.js" as="script"><link rel="prefetch" href="/assets/Gitgongzuoliu.html-fa6e129f.js" as="script"><link rel="prefetch" href="/assets/Typoratuchuang.html-22c57156.js" as="script"><link rel="prefetch" href="/assets/Vuepress.html-df146bdb.js" as="script"><link rel="prefetch" href="/assets/My2401.html-49f6440f.js" as="script"><link rel="prefetch" href="/assets/My2402.html-950d4e85.js" as="script"><link rel="prefetch" href="/assets/shenhai-0509.html-2007281b.js" as="script"><link rel="prefetch" href="/assets/zhuhaixing.html-17db8380.js" as="script"><link rel="prefetch" href="/assets/404.html-f9875e7b.js" as="script"><link rel="prefetch" href="/assets/index.html-40bced6f.js" as="script"><link rel="prefetch" href="/assets/index.html-3c78780e.js" as="script"><link rel="prefetch" href="/assets/index.html-ef51ba1b.js" as="script"><link rel="prefetch" href="/assets/index.html-bdec80a5.js" as="script"><link rel="prefetch" href="/assets/index.html-3b5427f8.js" as="script"><link rel="prefetch" href="/assets/index.html-cbd49540.js" as="script"><link rel="prefetch" href="/assets/index.html-b0b97c81.js" as="script"><link rel="prefetch" href="/assets/index.html-2793d245.js" as="script"><link rel="prefetch" href="/assets/index.html-71d9a5d9.js" as="script"><link rel="prefetch" href="/assets/index.html-4e7d77cd.js" as="script"><link rel="prefetch" href="/assets/index.html-aeace11a.js" as="script"><link rel="prefetch" href="/assets/index.html-c62ed802.js" as="script"><link rel="prefetch" href="/assets/index.html-e640d31f.js" as="script"><link rel="prefetch" href="/assets/index.html-48e1c605.js" as="script"><link rel="prefetch" href="/assets/index.html-385dcb56.js" as="script"><link rel="prefetch" href="/assets/index.html-1bb1a523.js" as="script"><link rel="prefetch" href="/assets/index.html-1ed80e8d.js" as="script"><link rel="prefetch" href="/assets/index.html-2c154a45.js" as="script"><link rel="prefetch" href="/assets/index.html-3e93d436.js" as="script"><link rel="prefetch" href="/assets/index.html-2a93e2c9.js" as="script"><link rel="prefetch" href="/assets/index.html-cff07ba3.js" as="script"><link rel="prefetch" href="/assets/index.html-7ec32a34.js" as="script"><link rel="prefetch" href="/assets/index.html-ddb40108.js" as="script"><link rel="prefetch" href="/assets/index.html-40ab6c4f.js" as="script"><link rel="prefetch" href="/assets/index.html-47e4ee8b.js" as="script"><link rel="prefetch" href="/assets/index.html-c15250e1.js" as="script"><link rel="prefetch" href="/assets/index.html-fb2ea2e4.js" as="script"><link rel="prefetch" href="/assets/index.html-d7e5408a.js" as="script"><link rel="prefetch" href="/assets/index.html-a38055d0.js" as="script"><link rel="prefetch" href="/assets/index.html-be4e50cb.js" as="script"><link rel="prefetch" href="/assets/index.html-660e4bef.js" as="script"><link rel="prefetch" href="/assets/index.html-98aa61ea.js" as="script"><link rel="prefetch" href="/assets/index.html-a6b7472f.js" as="script"><link rel="prefetch" href="/assets/index.html-ab78917a.js" as="script"><link rel="prefetch" href="/assets/biaoqian-fenlei-moban.html-f2c6c309.js" as="script"><link rel="prefetch" href="/assets/MuBan-Apai.html-5714876d.js" as="script"><link rel="prefetch" href="/assets/guide.html-9a89b22b.js" as="script"><link rel="prefetch" href="/assets/Lu-aboutMe.html-f8203e0a.js" as="script"><link rel="prefetch" href="/assets/kaishi.html-4ff9d0f3.js" as="script"><link rel="prefetch" href="/assets/Hobby-SheYing.html-e1ab7a00.js" as="script"><link rel="prefetch" href="/assets/Lu-aboutMe.html-4b735204.js" as="script"><link rel="prefetch" href="/assets/Work-MaYun.html-a185f330.js" as="script"><link rel="prefetch" href="/assets/Java-basics.html-c0d3a063.js" as="script"><link rel="prefetch" href="/assets/JavaAPI.html-f75cbb54.js" as="script"><link rel="prefetch" href="/assets/JavaBiKeng04.html-d2fc755d.js" as="script"><link rel="prefetch" href="/assets/JavaGongNeng03.html-c51a3060.js" as="script"><link rel="prefetch" href="/assets/JavaJinJie02.html-e5a66660.js" as="script"><link rel="prefetch" href="/assets/JavaMyUtil.html-6e16ee98.js" as="script"><link rel="prefetch" href="/assets/MyBatisPlus.html-1cafeb7e.js" as="script"><link rel="prefetch" href="/assets/MySql.html-5adc8c86.js" as="script"><link rel="prefetch" href="/assets/MySqlFunction.html-2c432c8c.js" as="script"><link rel="prefetch" href="/assets/RabbitMQ.html-d771200f.js" as="script"><link rel="prefetch" href="/assets/Redis.html-aa5c160a.js" as="script"><link rel="prefetch" href="/assets/ShiWuAffair.html-ce7fc825.js" as="script"><link rel="prefetch" href="/assets/Spring.html-3d622ed7.js" as="script"><link rel="prefetch" href="/assets/SpringConfig.html-6fe667f9.js" as="script"><link rel="prefetch" href="/assets/SpringPeiZhi.html-96b777da.js" as="script"><link rel="prefetch" href="/assets/SpringSecurity.html-fe792e2f.js" as="script"><link rel="prefetch" href="/assets/WebSocket.html-7fd7be86.js" as="script"><link rel="prefetch" href="/assets/DockerCompose.html-f6ef44c4.js" as="script"><link rel="prefetch" href="/assets/Linux.html-a1058183.js" as="script"><link rel="prefetch" href="/assets/Nginx.html-bf694d87.js" as="script"><link rel="prefetch" href="/assets/RabbitMQ_COPY.html-1e53d902.js" as="script"><link rel="prefetch" href="/assets/Redis_COPY.html-ef853ef3.js" as="script"><link rel="prefetch" href="/assets/Redis_CRUD.html-7a4bb7d5.js" as="script"><link rel="prefetch" href="/assets/BatJiaoBen.html-20ec59d7.js" as="script"><link rel="prefetch" href="/assets/EasyExcel.html-ac2c3493.js" as="script"><link rel="prefetch" href="/assets/GitLu.html-27823973.js" as="script"><link rel="prefetch" href="/assets/JavaKaiFa.html-ff11bb84.js" as="script"><link rel="prefetch" href="/assets/JSR303.html-0c745945.js" as="script"><link rel="prefetch" href="/assets/MinIO.html-958125dd.js" as="script"><link rel="prefetch" href="/assets/ShardingJDBC.html-ce0afe07.js" as="script"><link rel="prefetch" href="/assets/Swagger.html-9c9fb3be.js" as="script"><link rel="prefetch" href="/assets/Vuepress.html-4e07419a.js" as="script"><link rel="prefetch" href="/assets/Angular.html-3e716bd5.js" as="script"><link rel="prefetch" href="/assets/ElementUI.html-70835a6c.js" as="script"><link rel="prefetch" href="/assets/Html-Js.html-848bb521.js" as="script"><link rel="prefetch" href="/assets/Vue-basics.html-772005d8.js" as="script"><link rel="prefetch" href="/assets/Vue3_group.html-69369e84.js" as="script"><link rel="prefetch" href="/assets/Vue3_option.html-37ac05d4.js" as="script"><link rel="prefetch" href="/assets/ApifoxAPIceshi.html-0bcb1468.js" as="script"><link rel="prefetch" href="/assets/PDManeryuanshujianmo.html-4c377e02.js" as="script"><link rel="prefetch" href="/assets/OCRwenzishibie.html-b4248616.js" as="script"><link rel="prefetch" href="/assets/EasyExcelbiaogeku.html-511b0f0b.js" as="script"><link rel="prefetch" href="/assets/Javadaimashengchengqi.html-33991c95.js" as="script"><link rel="prefetch" href="/assets/JDKshuangbanben.html-8bba14d4.js" as="script"><link rel="prefetch" href="/assets/JSR303canshuxiaoyan.html-7d12c0ef.js" as="script"><link rel="prefetch" href="/assets/Mail  youjian.html-d520132f.js" as="script"><link rel="prefetch" href="/assets/MyBatisPlusxiangjie.html-94d1940a.js" as="script"><link rel="prefetch" href="/assets/MySQLzhucongfuzhi.html-bf156f04.js" as="script"><link rel="prefetch" href="/assets/Redis-API.html-534cd405.js" as="script"><link rel="prefetch" href="/assets/SpringBootshiwu.html-a83407ed.js" as="script"><link rel="prefetch" href="/assets/SpringBootduxiefenli.html-e50eba32.js" as="script"><link rel="prefetch" href="/assets/Springguolvqihelanjieqi.html-b7cdfd68.js" as="script"><link rel="prefetch" href="/assets/WebSocket.html-7c2b5253.js" as="script"><link rel="prefetch" href="/assets/quanjuyichang-JSR303.html-1f70d8b7.js" as="script"><link rel="prefetch" href="/assets/Docker.html-51026828.js" as="script"><link rel="prefetch" href="/assets/Dockeryuanchengfangwenbushu.html-f42be316.js" as="script"><link rel="prefetch" href="/assets/Nginxfanxiangdaili.html-a98dc972.js" as="script"><link rel="prefetch" href="/assets/Apai-SheYingOne.html-b5b7ae7c.js" as="script"><link rel="prefetch" href="/assets/Apai-Year.html-ce260a3f.js" as="script"><link rel="prefetch" href="/assets/My2305.html-8daa1c69.js" as="script"><link rel="prefetch" href="/assets/My2306.html-893e00c1.js" as="script"><link rel="prefetch" href="/assets/My2307.html-e78450ff.js" as="script"><link rel="prefetch" href="/assets/My2308.html-0e38205b.js" as="script"><link rel="prefetch" href="/assets/My2309.html-06a48ebc.js" as="script"><link rel="prefetch" href="/assets/My2310.html-59afa2c3.js" as="script"><link rel="prefetch" href="/assets/My2311.html-b634eab1.js" as="script"><link rel="prefetch" href="/assets/My2312.html-aafaa08a.js" as="script"><link rel="prefetch" href="/assets/Yi-HuBei.html-61c8ef5d.js" as="script"><link rel="prefetch" href="/assets/Yi-ZhuHai.html-26a46f60.js" as="script"><link rel="prefetch" href="/assets/Apache ECharts tubiao.html-e9cc0012.js" as="script"><link rel="prefetch" href="/assets/Vue3 zuheshi API.html-11ae0fbc.js" as="script"><link rel="prefetch" href="/assets/Vue3 xuanxiangshi API.html-ce744458.js" as="script"><link rel="prefetch" href="/assets/Vue3-i18n-guojihuachajian.html-1fa338e8.js" as="script"><link rel="prefetch" href="/assets/Batpichulijiaoben.html-06ab27bc.js" as="script"><link rel="prefetch" href="/assets/Gitgongzuoliu.html-b1e45d5c.js" as="script"><link rel="prefetch" href="/assets/Typoratuchuang.html-cb5c9b25.js" as="script"><link rel="prefetch" href="/assets/Vuepress.html-c36453a2.js" as="script"><link rel="prefetch" href="/assets/My2401.html-9b16cb88.js" as="script"><link rel="prefetch" href="/assets/My2402.html-3ade37a1.js" as="script"><link rel="prefetch" href="/assets/shenhai-0509.html-648d7d95.js" as="script"><link rel="prefetch" href="/assets/zhuhaixing.html-7d486783.js" as="script"><link rel="prefetch" href="/assets/404.html-7c90b0cc.js" as="script"><link rel="prefetch" href="/assets/reco-valine-a0c1af1f.js" as="script">
    <link rel="preload" href="/assets/style-8a0f09c6.css" as="style"><link rel="stylesheet" href="/assets/style-8a0f09c6.css">
  </head>
  <body>
    <div id="app"><!--[--><div class="theme-container"><div class="common-wrapper show-series show-catalog"><div><header class="navbar-container"><!--[--><div class="site-brand nav-item"><img class="logo" src="/logo.png" alt="阿派 | Apai Blog"><a href="/" class="site-name can-hide">阿派 | Apai Blog</a></div><div class="nav-item navbar-links-wrapper" style=""><form class="search-box" role="search"><input type="search" autocomplete="off" spellcheck="false" value><!----></form><nav class="navbar-links"><!--[--><div class="navbar-links__item"><a href="/" class="link router-link-active" aria-label="Home"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Home<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><a href="/categories/Java/1/" class="link" aria-label="分类组"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->分类组<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><a href="/tags/Rests/1/" class="link" aria-label="标签组"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->标签组<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="文档组"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档组<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="文档组"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档组<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/docs/Web-develop/Html-Js" class="link" aria-label="Web-开发"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Web-开发<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Java-develop/JavaMyUtil" class="link" aria-label="Java-开发"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Java-开发<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Linux-develop/Linux" class="link" aria-label="Linux-系统"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Linux-系统<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Rests-docs/Vuepress" class="link" aria-label="Apai-其他"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Apai-其他<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="花圃里"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->花圃里<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="花圃里"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->花圃里<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/docs/Apai-MyRecord/My-2023/My2307" class="link" aria-label="2023-花开万里"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2023-花开万里<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Apai-MyRecord/My-2024/My2401" class="link" aria-label="2024-随心而来"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2024-随心而来<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><a href="/docs/Apai-AboutMe/Lu-aboutMe" class="link" aria-label="关于我"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->关于我<!--]--></span></span><!--[--><!--]--></a></div><!--]--></nav><span class="xicon-container btn-toggle-dark-mode btn--dark-mode"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" style="width:20px;height:20px;font-size:20px;color:inherit;"><path d="M15 2h2v3h-2z" fill="currentColor"></path><path d="M27 15h3v2h-3z" fill="currentColor"></path><path d="M15 27h2v3h-2z" fill="currentColor"></path><path d="M2 15h3v2H2z" fill="currentColor"></path><path d="M5.45 6.884l1.414-1.415l2.121 2.122l-1.414 1.414z" fill="currentColor"></path><path d="M23 7.58l2.121-2.12l1.414 1.414l-2.121 2.121z" fill="currentColor"></path><path d="M23.002 24.416l1.415-1.414l2.12 2.122l-1.413 1.414z" fill="currentColor"></path><path d="M5.47 25.13L7.59 23L9 24.42l-2.12 2.12l-1.41-1.41z" fill="currentColor"></path><path d="M16 8a8 8 0 1 0 8 8a8 8 0 0 0-8-8zm0 14a6 6 0 0 1 0-12z" fill="currentColor"></path></svg></span><span class="xicon-container btn-toggle-menus"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" style="width:20px;height:20px;font-size:20px;color:inherit;"><circle cx="16" cy="8" r="2" fill="currentColor"></circle><circle cx="16" cy="16" r="2" fill="currentColor"></circle><circle cx="16" cy="24" r="2" fill="currentColor"></circle></svg></span></div><!--]--></header><div class="mobile-menus-container"><nav class="navbar-links mobile"><!--[--><div class="navbar-links__item"><a href="/" class="link router-link-active" aria-label="Home"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Home<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><a href="/categories/Java/1/" class="link" aria-label="分类组"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->分类组<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><a href="/tags/Rests/1/" class="link" aria-label="标签组"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->标签组<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="文档组"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档组<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="文档组"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档组<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/docs/Web-develop/Html-Js" class="link" aria-label="Web-开发"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Web-开发<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Java-develop/JavaMyUtil" class="link" aria-label="Java-开发"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Java-开发<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Linux-develop/Linux" class="link" aria-label="Linux-系统"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Linux-系统<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Rests-docs/Vuepress" class="link" aria-label="Apai-其他"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Apai-其他<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="花圃里"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->花圃里<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="花圃里"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->花圃里<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/docs/Apai-MyRecord/My-2023/My2307" class="link" aria-label="2023-花开万里"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2023-花开万里<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Apai-MyRecord/My-2024/My2401" class="link" aria-label="2024-随心而来"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2024-随心而来<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><a href="/docs/Apai-AboutMe/Lu-aboutMe" class="link" aria-label="关于我"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->关于我<!--]--></span></span><!--[--><!--]--></a></div><!--]--></nav><div class="appearance"><span>Appearance</span><span class="xicon-container btn-toggle-dark-mode"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" style="width:20px;height:20px;font-size:20px;color:inherit;"><path d="M15 2h2v3h-2z" fill="currentColor"></path><path d="M27 15h3v2h-3z" fill="currentColor"></path><path d="M15 27h2v3h-2z" fill="currentColor"></path><path d="M2 15h3v2H2z" fill="currentColor"></path><path d="M5.45 6.884l1.414-1.415l2.121 2.122l-1.414 1.414z" fill="currentColor"></path><path d="M23 7.58l2.121-2.12l1.414 1.414l-2.121 2.121z" fill="currentColor"></path><path d="M23.002 24.416l1.415-1.414l2.12 2.122l-1.413 1.414z" fill="currentColor"></path><path d="M5.47 25.13L7.59 23L9 24.42l-2.12 2.12l-1.41-1.41z" fill="currentColor"></path><path d="M16 8a8 8 0 1 0 8 8a8 8 0 0 0-8-8zm0 14a6 6 0 0 1 0-12z" fill="currentColor"></path></svg></span></div></div><div class="series-mask"></div><aside class="series-container"><div class="site-brand"><img class="logo" src="/logo.png" alt="阿派 | Apai Blog"><a href="/" class="site-name can-hide">阿派 | Apai Blog</a></div><!--[--><!--[--><section class="series-group series-item"><h5 class="series-heading active">My Apai</h5><ul><li><!--[--><a href="/docs/Rests-docs/JavaKaiFa.html" class="link series-item" aria-label="Java 开发的工具"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Java 开发的工具<!--]--></span></span><!--[--><!--]--></a><!--]--></li><li><!--[--><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html" class="router-link-active router-link-exact-active link router-link-active series-item active" aria-label="Java 代码生成器"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Java 代码生成器<!--]--></span></span><!--[--><!--]--></a><!--]--></li></ul></section><!--]--><!--[--><section class="series-group series-item"><h5 class="series-heading">Apai 大杂烩</h5><ul><li><!--[--><a href="/docs/Rests-docs/Vuepress.html" class="link series-item" aria-label="个人网站搭建"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->个人网站搭建<!--]--></span></span><!--[--><!--]--></a><!--]--></li><li><!--[--><a href="/docs/Rests-docs/GitLu.html" class="link series-item" aria-label="Git 工作流"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Git 工作流<!--]--></span></span><!--[--><!--]--></a><!--]--></li><li><!--[--><a href="/docs/Rests-docs/BatJiaoBen.html" class="link series-item" aria-label="Bat 批处理脚本"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Bat 批处理脚本<!--]--></span></span><!--[--><!--]--></a><!--]--></li></ul></section><!--]--><!--[--><section class="series-group series-item"><h5 class="series-heading">技术组</h5><ul><li><!--[--><a href="/docs/Rests-docs/ShardingJDBC.html" class="link series-item" aria-label="Spring 分库分表"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Spring 分库分表<!--]--></span></span><!--[--><!--]--></a><!--]--></li><li><!--[--><a href="/docs/Rests-docs/Swagger.html" class="link series-item" aria-label="Swagger 接口测试"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Swagger 接口测试<!--]--></span></span><!--[--><!--]--></a><!--]--></li><li><!--[--><a href="/docs/Rests-docs/EasyExcel.html" class="link series-item" aria-label="Easy Excel 表格库"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Easy Excel 表格库<!--]--></span></span><!--[--><!--]--></a><!--]--></li><li><!--[--><a href="/docs/Rests-docs/JSR303.html" class="link series-item" aria-label="JSR303n 参数校验"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->JSR303n 参数校验<!--]--></span></span><!--[--><!--]--></a><!--]--></li></ul></section><!--]--><!--[--><section class="series-group series-item"><h5 class="series-heading">工具组</h5><ul><li><!--[--><a href="/docs/Rests-docs/MinIO.html" class="link series-item" aria-label="MinIO 对象存储"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->MinIO 对象存储<!--]--></span></span><!--[--><!--]--></a><!--]--></li></ul></section><!--]--><!--]--></aside><!--[--><main class="page-container"><h1 class="page-title">Java 代码生成器</h1><div class="page-info"><span class="xicon-container left"><!--[--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="xicon-icon" style="width:18px;height:18px;font-size:18px;color:inherit;"><path d="M16 4a5 5 0 1 1-5 5a5 5 0 0 1 5-5m0-2a7 7 0 1 0 7 7a7 7 0 0 0-7-7z" fill="currentColor"></path><path d="M26 30h-2v-5a5 5 0 0 0-5-5h-6a5 5 0 0 0-5 5v5H6v-5a7 7 0 0 1 7-7h6a7 7 0 0 1 7 7z" fill="currentColor"></path></svg><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->LuisApai<!--]--></span></span><span class="xicon-container left"><!--[--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="xicon-icon" style="width:18px;height:18px;font-size:18px;color:inherit;"><path d="M26 4h-4V2h-2v2h-8V2h-2v2H6c-1.1 0-2 .9-2 2v20c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 22H6V12h20v14zm0-16H6V6h4v2h2V6h8v2h2V6h4v4z" fill="currentColor"></path></svg><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2023/05/12<!--]--></span></span><!----><!----><!----></div><div class="theme-reco-default-content"><div><h2 id="mybatis-代码生成器" tabindex="-1"><a class="header-anchor" href="#mybatis-代码生成器" aria-hidden="true">#</a> Mybatis - 代码生成器</h2><h3 id="pom-xml-生成器插件配置" tabindex="-1"><a class="header-anchor" href="#pom-xml-生成器插件配置" aria-hidden="true">#</a> pom.xml 生成器插件配置</h3><div class="language-txt line-numbers-mode" data-ext="txt"><pre class="language-txt"><code>mybatis - 代码生成器 pom.xml  的 &lt;plugins&gt; 插件标签内
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><div class="language-xml line-numbers-mode" data-ext="xml"><pre class="language-xml"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>plugin</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.mybatis.generator<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>mybatis-generator-maven-plugin<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.4.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span> <span class="token comment">&lt;!-- 不要低于 1.3.7 版本 --&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependencies</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>mysql<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>mysql-connector-java<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>8.0.22<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.mybatis.generator<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>mybatis-generator-core<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.4.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span> <span class="token comment">&lt;!-- 不要低于 1.3.7 版本 --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependencies</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>configuration</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>verbose</span><span class="token punctuation">&gt;</span></span>true<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>verbose</span><span class="token punctuation">&gt;</span></span> <span class="token comment">&lt;!-- 允许移动生成的文件 --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>overwrite</span><span class="token punctuation">&gt;</span></span>true<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>overwrite</span><span class="token punctuation">&gt;</span></span> <span class="token comment">&lt;!-- 是否覆盖 --&gt;</span>
        <span class="token comment">&lt;!--配置文件的路径 --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>configurationFile</span><span class="token punctuation">&gt;</span></span>src/main/resources/generatorConfig.xml<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>configurationFile</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>configuration</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>plugin</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="generatorconfig-xml-配置" tabindex="-1"><a class="header-anchor" href="#generatorconfig-xml-配置" aria-hidden="true">#</a> generatorConfig.xml 配置</h3><blockquote><p>代码生成器的启动类</p><p>注意: 可配置 数据库 和 表 的实体类 数据访问层 的配置 开启自动生成</p></blockquote><div class="language-xml line-numbers-mode" data-ext="xml"><pre class="language-xml"><code><span class="token doctype"><span class="token punctuation">&lt;!</span><span class="token doctype-tag">DOCTYPE</span> <span class="token name">generatorConfiguration</span>
        <span class="token name">PUBLIC</span> <span class="token string">&quot;-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN&quot;</span>
        <span class="token string">&quot;http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd&quot;</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>generatorConfiguration</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>context</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>smbms<span class="token punctuation">&quot;</span></span>   <span class="token attr-name">targetRuntime</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>MyBatis3<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- 覆盖生成 XML 文件的 Bug 解决 --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>plugin</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>commentGenerator</span><span class="token punctuation">&gt;</span></span>
            <span class="token comment">&lt;!--关闭时间注释 --&gt;</span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>suppressDate<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
            <span class="token comment">&lt;!-- 是否去除自动生成的注释 true：是 ： false:否 --&gt;</span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>suppressAllComments<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>commentGenerator</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!--数据库链接URL，用户名、密码 --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>jdbcConnection</span> <span class="token attr-name">driverClass</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>com.mysql.cj.jdbc.Driver<span class="token punctuation">&quot;</span></span>
                        <span class="token attr-name">connectionURL</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>jdbc:mysql://localhost:3306/smbms?useSSL=false<span class="token entity named-entity" title="&amp;">&amp;amp;</span>serverTimezone=UTC<span class="token punctuation">&quot;</span></span>
                        <span class="token attr-name">userId</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>root<span class="token punctuation">&quot;</span></span> <span class="token attr-name">password</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>123456<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>jdbcConnection</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>javaTypeResolver</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>forceBigDecimals<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>false<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>javaTypeResolver</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- 生成po的包名和位置--&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>javaModelGenerator</span> <span class="token attr-name">targetPackage</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>com.woniu.entity<span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetProject</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>src/main/java<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>enableSubPackages<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>trimStrings<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>javaModelGenerator</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- 生成映射XML文件的包名和位置--&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>sqlMapGenerator</span> <span class="token attr-name">targetPackage</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>com.woniu.mapper<span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetProject</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>src/main/java<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>enableSubPackages<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>sqlMapGenerator</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- 生成dao文件包名和位置--&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>javaClientGenerator</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>XMLMAPPER<span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetPackage</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>com.woniu.mapper<span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetProject</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>src/main/java<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>enableSubPackages<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>javaClientGenerator</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- 要生成哪些表--&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>table</span> <span class="token attr-name">tableName</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>smbms_role<span class="token punctuation">&quot;</span></span> <span class="token attr-name">catalog</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>smbms<span class="token punctuation">&quot;</span></span>   <span class="token attr-name">domainObjectName</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>Role<span class="token punctuation">&quot;</span></span>
               <span class="token attr-name">enableCountByExample</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span>
               <span class="token attr-name">enableUpdateByExample</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span>
               <span class="token attr-name">enableDeleteByExample</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span>
               <span class="token attr-name">enableSelectByExample</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span> <span class="token attr-name">selectByExampleQueryId</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>ignoreQualifiersAtRuntime<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>generatedKey</span> <span class="token attr-name">column</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>id<span class="token punctuation">&quot;</span></span> <span class="token attr-name">sqlStatement</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>Mysql<span class="token punctuation">&quot;</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>post<span class="token punctuation">&quot;</span></span> <span class="token attr-name">identity</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>table</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>context</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>generatorConfiguration</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="运行自动生成" tabindex="-1"><a class="header-anchor" href="#运行自动生成" aria-hidden="true">#</a> 运行自动生成</h3><p><img src="https://gitee.com/LuisApai/Apai_image_MD/raw/master/md_image/image-20220601174717702.png" alt="image-20220601174717702"></p><h2 id="mybatis-plus-代码生成器" tabindex="-1"><a class="header-anchor" href="#mybatis-plus-代码生成器" aria-hidden="true">#</a> Mybatis-plus 代码生成器</h2><h3 id="添加依赖" tabindex="-1"><a class="header-anchor" href="#添加依赖" aria-hidden="true">#</a> 添加依赖</h3><blockquote><p>pom.xml 文件内</p><p>特别注意: 还要 Mybatis-plus 依赖 但是与分页插件有依赖冲突</p></blockquote><div class="language-xml line-numbers-mode" data-ext="xml"><pre class="language-xml"><code><span class="token comment">&lt;!--mybatis-plus 启动器--&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.baomidou<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>mybatis-plus-boot-starter<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>3.4.2<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
<span class="token comment">&lt;!--mybatis-plus 代码生成器--&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.baomidou<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>mybatis-plus-generator<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>3.5.1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
<span class="token comment">&lt;!--mybatis-plus 代码生成器模板引擎--&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.freemarker<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>freemarker<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>2.3.31<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>

<span class="token comment">&lt;!--分页插件 依赖冲突排除--&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.github.pagehelper<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>pagehelper-spring-boot-starter<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.2.5<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>exclusions</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>exclusion</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.mybatis<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>mybatis<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>exclusion</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>exclusion</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.mybatis<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>mybatis-spring<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>exclusion</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>exclusions</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="添加-模板引擎" tabindex="-1"><a class="header-anchor" href="#添加-模板引擎" aria-hidden="true">#</a> 添加 模板引擎</h3><blockquote><p><strong>可直接写在测试类里</strong> 使用单元测试开启 即可</p><p>注意: 更改对应的配置 实体类 自动生成set和get 需修改 @Data 注解</p></blockquote><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>generator<span class="token punctuation">.</span></span><span class="token class-name">FastAutoGenerator</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>generator<span class="token punctuation">.</span>config<span class="token punctuation">.</span></span><span class="token class-name">OutputFile</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>generator<span class="token punctuation">.</span>config<span class="token punctuation">.</span>rules<span class="token punctuation">.</span></span><span class="token class-name">NamingStrategy</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>generator<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span><span class="token class-name">FreemarkerTemplateEngine</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>junit<span class="token punctuation">.</span>jupiter<span class="token punctuation">.</span>api<span class="token punctuation">.</span></span><span class="token class-name">Test</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Collections</span></span><span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MybatisPlusGenerator</span> <span class="token punctuation">{</span>


    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">generator</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">//生成的文件放置目录 必须以 &#39;\\ 或者 /&#39; 结尾</span>
        <span class="token class-name">String</span> outputDir <span class="token operator">=</span> <span class="token string">&quot;C:/Users/Lujun/Documents/IDEA/SpringBootParent/SpringBootParent/SpringApai02/src/main/java/&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">//设置父包名</span>
        <span class="token class-name">String</span> packageName <span class="token operator">=</span> <span class="token string">&quot;com.apai&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">// 数据库信息</span>
        <span class="token class-name">String</span> mapperXmlDir <span class="token operator">=</span> outputDir <span class="token operator">+</span> packageName<span class="token punctuation">.</span><span class="token function">replaceAll</span><span class="token punctuation">(</span><span class="token string">&quot;\\.&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;/&quot;</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">&quot;/mapper&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> url <span class="token operator">=</span> <span class="token string">&quot;jdbc:mysql://localhost:3306/smbms?useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=false&amp;nullCatalogMeansCurrent=true&amp;serverTimezone=Asia/Shanghai&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">FastAutoGenerator</span><span class="token punctuation">.</span><span class="token function">create</span><span class="token punctuation">(</span>url<span class="token punctuation">,</span> <span class="token string">&quot;root&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;123456&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">globalConfig</span><span class="token punctuation">(</span>builder <span class="token operator">-&gt;</span> <span class="token punctuation">{</span>
                    <span class="token comment">// 设置作者</span>
                    builder<span class="token punctuation">.</span><span class="token function">author</span><span class="token punctuation">(</span><span class="token string">&quot;阿派&quot;</span><span class="token punctuation">)</span>
                            <span class="token comment">// 开启 swagger 模式</span>
                            <span class="token comment">// .enableSwagger()</span>
                            <span class="token comment">// 覆盖已生成文件</span>
                            <span class="token punctuation">.</span><span class="token function">fileOverride</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                            <span class="token comment">// 指定输出目录</span>
                            <span class="token punctuation">.</span><span class="token function">outputDir</span><span class="token punctuation">(</span>outputDir<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">packageConfig</span><span class="token punctuation">(</span>builder <span class="token operator">-&gt;</span> <span class="token punctuation">{</span>
                    <span class="token comment">// 设置父包名</span>
                    builder<span class="token punctuation">.</span><span class="token function">parent</span><span class="token punctuation">(</span>packageName<span class="token punctuation">)</span>
                            <span class="token comment">// 设置mapperXml生成路径</span>
                            <span class="token punctuation">.</span><span class="token function">pathInfo</span><span class="token punctuation">(</span><span class="token class-name">Collections</span><span class="token punctuation">.</span><span class="token function">singletonMap</span><span class="token punctuation">(</span><span class="token class-name">OutputFile</span><span class="token punctuation">.</span>mapperXml<span class="token punctuation">,</span> mapperXmlDir<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">strategyConfig</span><span class="token punctuation">(</span>builder <span class="token operator">-&gt;</span> <span class="token punctuation">{</span>
                    builder<span class="token punctuation">.</span><span class="token function">addInclude</span><span class="token punctuation">(</span><span class="token string">&quot;smbms_user&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;smbms_role&quot;</span><span class="token punctuation">)</span>  <span class="token comment">//给该表生成</span>
                            <span class="token punctuation">.</span><span class="token function">addTablePrefix</span><span class="token punctuation">(</span><span class="token string">&quot;smbms_&quot;</span><span class="token punctuation">)</span> <span class="token comment">//设置过滤表前缀</span>
                            <span class="token punctuation">.</span><span class="token function">entityBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">enableLombok</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">//entity 使用 lombok</span>
                        	<span class="token comment">//不开启驼峰: NamingStrategy.no_change 带下划线的表会自动生成注解</span>
                        	<span class="token comment">// 开启驼峰:NamingStrategy.underline_to_camel 注意更改yml配置</span>
                            <span class="token punctuation">.</span><span class="token function">entityBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">columnNaming</span><span class="token punctuation">(</span><span class="token class-name">NamingStrategy</span><span class="token punctuation">.</span>no_change<span class="token punctuation">)</span>
                            <span class="token punctuation">.</span><span class="token function">controllerBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">//创建Controller</span>
                            <span class="token comment">// .enableRestStyle() //使用restController</span>
                            <span class="token punctuation">.</span><span class="token function">mapperBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">enableMapperAnnotation</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//开启mapper注解</span>
                    <span class="token comment">// 使用Freemarker引擎模板，默认的是Velocity引擎模板</span>
                <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">templateEngine</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">FreemarkerTemplateEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">execute</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="三层-代码生成器" tabindex="-1"><a class="header-anchor" href="#三层-代码生成器" aria-hidden="true">#</a> 三层 代码生成器</h3><blockquote><p>基于: Mybatis-plus 代码生成器修改而来 | 需要对应的依赖</p><p>可根据官网进行配置修改: https://baomidou.com/pages/981406/#%E6%95%B0%E6%8D%AE%E5%BA%93%E9%85%8D%E7%BD%AE-datasourceconfig</p></blockquote><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>apai</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>generator<span class="token punctuation">.</span></span><span class="token class-name">FastAutoGenerator</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>generator<span class="token punctuation">.</span>config<span class="token punctuation">.</span></span><span class="token class-name">OutputFile</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>generator<span class="token punctuation">.</span>config<span class="token punctuation">.</span>rules<span class="token punctuation">.</span></span><span class="token class-name">NamingStrategy</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>generator<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span><span class="token class-name">FreemarkerTemplateEngine</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Collections</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token keyword">static</span> <span class="token import static"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">IdType</span><span class="token punctuation">.</span><span class="token static">ASSIGN_ID</span></span><span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MybatisPlusGenerator</span> <span class="token punctuation">{</span>

    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> <span class="token punctuation">{</span>

        <span class="token comment">// &lt;----- 代码生成器必须指定项 -----&gt;</span>
        <span class="token comment">// 生成的文件放置目录 必须以 &#39;\\ 或者 /&#39; 结尾 如: F:/paidaxing/</span>
        <span class="token class-name">String</span> outputDir <span class="token operator">=</span> <span class="token string">&quot;F:/paidaxing11/&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">// 设置父包名 如: com.apai</span>
        <span class="token class-name">String</span> packageName <span class="token operator">=</span> <span class="token string">&quot;com.apai&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">// 数据库连接信息</span>
        <span class="token class-name">String</span> url <span class="token operator">=</span> <span class="token string">&quot;jdbc:mysql://localhost:3306/strangerthings?serverTimezone=UTC&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> name <span class="token operator">=</span> <span class="token string">&quot;root&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> password <span class="token operator">=</span> <span class="token string">&quot;123456&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">// 需要生成的表名 及 表前缀</span>
        <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> tableNames <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;user&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;category&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;jurisdiction&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;permission&quot;</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> tablePrefix <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;&quot;</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
        <span class="token comment">// 项目作者名称</span>
        <span class="token class-name">String</span> author <span class="token operator">=</span> <span class="token string">&quot;是阿派啊&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">// 指定 mapperXml文件 的位置</span>
        <span class="token class-name">String</span> mapperXmlDir <span class="token operator">=</span> outputDir <span class="token operator">+</span> packageName<span class="token punctuation">.</span><span class="token function">replaceAll</span><span class="token punctuation">(</span><span class="token string">&quot;\\.&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;/&quot;</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">&quot;/mapper&quot;</span><span class="token punctuation">;</span>

        <span class="token comment">// 创建备用文件夹</span>
<span class="token comment">//        String context = outputDir + packageName.replaceAll(&quot;\\.&quot;, &quot;/&quot;);</span>
<span class="token comment">//        String[] folders = {</span>
<span class="token comment">//                &quot;/inlet/web/vo&quot;</span>
<span class="token comment">//        };</span>
<span class="token comment">//        for (String folder : folders) {</span>
<span class="token comment">//            new File(context + folder).mkdirs();</span>
<span class="token comment">//        }</span>

        <span class="token comment">// 根据信息 开始生成代码</span>
        <span class="token class-name">FastAutoGenerator</span><span class="token punctuation">.</span><span class="token function">create</span><span class="token punctuation">(</span>url<span class="token punctuation">,</span> name<span class="token punctuation">,</span> password<span class="token punctuation">)</span>
                <span class="token comment">// --- 全局配置(GlobalConfig)</span>
                <span class="token punctuation">.</span><span class="token function">globalConfig</span><span class="token punctuation">(</span>builder <span class="token operator">-&gt;</span> <span class="token punctuation">{</span>
                    builder<span class="token punctuation">.</span><span class="token function">author</span><span class="token punctuation">(</span>author<span class="token punctuation">)</span> <span class="token comment">// 设置作者</span>
                            <span class="token punctuation">.</span><span class="token function">enableSwagger</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 开启 swagger 模式</span>
                            <span class="token punctuation">.</span><span class="token function">fileOverride</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 覆盖已生成文件</span>
                            <span class="token punctuation">.</span><span class="token function">outputDir</span><span class="token punctuation">(</span>outputDir<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 指定输出目录</span>
                <span class="token punctuation">}</span><span class="token punctuation">)</span>
                <span class="token comment">// --- 包配置(PackageConfig)</span>
                <span class="token punctuation">.</span><span class="token function">packageConfig</span><span class="token punctuation">(</span>builder <span class="token operator">-&gt;</span> <span class="token punctuation">{</span>
                    <span class="token comment">// 设置父包名</span>
                    builder<span class="token punctuation">.</span><span class="token function">parent</span><span class="token punctuation">(</span>packageName<span class="token punctuation">)</span>
                            <span class="token punctuation">.</span><span class="token function">pathInfo</span><span class="token punctuation">(</span><span class="token class-name">Collections</span><span class="token punctuation">.</span><span class="token function">singletonMap</span><span class="token punctuation">(</span><span class="token class-name">OutputFile</span><span class="token punctuation">.</span>mapperXml<span class="token punctuation">,</span> mapperXmlDir<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 设置mapperXml生成路径</span>
                <span class="token punctuation">}</span><span class="token punctuation">)</span>
                <span class="token comment">// --- 策略配置(StrategyConfig)</span>
                <span class="token punctuation">.</span><span class="token function">strategyConfig</span><span class="token punctuation">(</span>builder <span class="token operator">-&gt;</span> <span class="token punctuation">{</span>
                    builder<span class="token punctuation">.</span><span class="token function">addInclude</span><span class="token punctuation">(</span>tableNames<span class="token punctuation">)</span>  <span class="token comment">// 给该表生成</span>
                            <span class="token punctuation">.</span><span class="token function">addTablePrefix</span><span class="token punctuation">(</span>tablePrefix<span class="token punctuation">)</span> <span class="token comment">// 设置过滤表前缀</span>
                            <span class="token comment">// 实体类配置</span>
                            <span class="token punctuation">.</span><span class="token function">entityBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                            <span class="token punctuation">.</span><span class="token function">enableLombok</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// entity 使用 lombok 注解</span>
                            <span class="token punctuation">.</span><span class="token function">idType</span><span class="token punctuation">(</span><span class="token constant">ASSIGN_ID</span><span class="token punctuation">)</span> <span class="token comment">// 设置自动生成主键类型的策略</span>
                            <span class="token punctuation">.</span><span class="token function">columnNaming</span><span class="token punctuation">(</span><span class="token class-name">NamingStrategy</span><span class="token punctuation">.</span>no_change<span class="token punctuation">)</span> <span class="token comment">// 驼峰:数据库列名到实体类字段名的映射策略</span>
                            <span class="token comment">// 业务层配置</span>
                            <span class="token punctuation">.</span><span class="token function">serviceBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                            <span class="token comment">// 表现层配置</span>
                            <span class="token punctuation">.</span><span class="token function">controllerBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                            <span class="token punctuation">.</span><span class="token function">enableRestStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 开启生成 @RestController 控制器</span>
                            <span class="token comment">// 数据层配置</span>
                            <span class="token punctuation">.</span><span class="token function">mapperBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                            <span class="token punctuation">.</span><span class="token function">enableMapperAnnotation</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 开启 mapper 注解</span>
                <span class="token punctuation">}</span><span class="token punctuation">)</span>
                <span class="token comment">// --- 模板配置(TemplateConfig)</span>
                <span class="token punctuation">.</span><span class="token function">templateEngine</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">FreemarkerTemplateEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// 使用 Freemarker引擎模板，默认的是Velocity引擎模板</span>
                <span class="token punctuation">.</span><span class="token function">execute</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="自定义位置-代码生成器" tabindex="-1"><a class="header-anchor" href="#自定义位置-代码生成器" aria-hidden="true">#</a> 自定义位置 代码生成器</h3><blockquote><p>基于: Mybatis-plus 代码生成器修改而来 | 需要对应的依赖</p><p>可根据官网进行配置修改: https://baomidou.com/pages/981406/#%E6%95%B0%E6%8D%AE%E5%BA%93%E9%85%8D%E7%BD%AE-datasourceconfig</p></blockquote><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>apai</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>generator<span class="token punctuation">.</span></span><span class="token class-name">FastAutoGenerator</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>generator<span class="token punctuation">.</span>config<span class="token punctuation">.</span>rules<span class="token punctuation">.</span></span><span class="token class-name">NamingStrategy</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>generator<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span><span class="token class-name">FreemarkerTemplateEngine</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">File</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token keyword">static</span> <span class="token import static"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">IdType</span><span class="token punctuation">.</span><span class="token static">ASSIGN_ID</span></span><span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MybatisPlusGenerator</span> <span class="token punctuation">{</span>


    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> <span class="token punctuation">{</span>

        <span class="token comment">// &lt;----- 代码生成器必须指定项 -----&gt;</span>
        <span class="token comment">// 生成的文件放置目录 必须以 &#39;\\ 或者 /&#39; 结尾 如: F:/paidaxing/</span>
        <span class="token class-name">String</span> outputDir <span class="token operator">=</span> <span class="token string">&quot;F:/paidaxing/&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">// 设置父包名 如: com.apai</span>
        <span class="token class-name">String</span> packageName <span class="token operator">=</span> <span class="token string">&quot;com.apai&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">// 数据库连接信息</span>
        <span class="token class-name">String</span> url <span class="token operator">=</span> <span class="token string">&quot;jdbc:mysql://localhost:3306/strangerthings?serverTimezone=UTC&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> name <span class="token operator">=</span> <span class="token string">&quot;root&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> password <span class="token operator">=</span> <span class="token string">&quot;123456&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">// 需要生成的表名 及 表前缀</span>
        <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> tableNames <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;user&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;category&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;jurisdiction&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;permission&quot;</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> tablePrefix <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;&quot;</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
        <span class="token comment">// 项目作者名称</span>
        <span class="token class-name">String</span> author <span class="token operator">=</span> <span class="token string">&quot;apai&quot;</span><span class="token punctuation">;</span>

        <span class="token comment">// 指定文件的位置 [. --&gt; /] 注意:开头不要是&quot;.&quot; 与类的包位置有关</span>
        <span class="token class-name">String</span> controllerDir <span class="token operator">=</span> <span class="token string">&quot;inlet.web&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> serviceImplDir <span class="token operator">=</span> <span class="token string">&quot;service.impl&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> serviceDir <span class="token operator">=</span> <span class="token string">&quot;service&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> mapperDir <span class="token operator">=</span> <span class="token string">&quot;outlet.mapper&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> mapperXmlDir <span class="token operator">=</span> <span class="token string">&quot;outlet.mapper&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> entityDir <span class="token operator">=</span> <span class="token string">&quot;outlet.po&quot;</span><span class="token punctuation">;</span>

        <span class="token comment">// 创建备用文件夹</span>
        <span class="token class-name">String</span> context <span class="token operator">=</span> outputDir <span class="token operator">+</span> packageName<span class="token punctuation">.</span><span class="token function">replaceAll</span><span class="token punctuation">(</span><span class="token string">&quot;\\.&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;/&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> folders <span class="token operator">=</span> <span class="token punctuation">{</span>
                <span class="token string">&quot;/inlet/web/vo&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;/inlet/subcribe&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;/inlet/timer&quot;</span><span class="token punctuation">,</span><span class="token comment">// 表现层文件夹</span>
                <span class="token string">&quot;/service/dto&quot;</span><span class="token punctuation">,</span> <span class="token comment">// 业务层文件夹</span>
                <span class="token string">&quot;/outlet/rides&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;/outlet/es&quot;</span><span class="token punctuation">,</span> <span class="token comment">// 数据层文件夹</span>
                <span class="token string">&quot;/config/rabbitMq&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;/config/security&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;/config/otherfolders&quot;</span><span class="token punctuation">,</span> <span class="token comment">// 配置文件夹</span>
                <span class="token string">&quot;/adapter&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;/exception&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;/utils&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">String</span> folder <span class="token operator">:</span> folders<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>context <span class="token operator">+</span> folder<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">mkdirs</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token comment">// 根据信息 开始生成代码</span>
        <span class="token class-name">FastAutoGenerator</span><span class="token punctuation">.</span><span class="token function">create</span><span class="token punctuation">(</span>url<span class="token punctuation">,</span> name<span class="token punctuation">,</span> password<span class="token punctuation">)</span>
                <span class="token comment">// --- 全局配置(GlobalConfig)</span>
                <span class="token punctuation">.</span><span class="token function">globalConfig</span><span class="token punctuation">(</span>builder <span class="token operator">-&gt;</span> <span class="token punctuation">{</span>
                    builder<span class="token punctuation">.</span><span class="token function">author</span><span class="token punctuation">(</span>author<span class="token punctuation">)</span> <span class="token comment">// 设置作者</span>
                            <span class="token punctuation">.</span><span class="token function">enableSwagger</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 开启 swagger 模式</span>
                            <span class="token punctuation">.</span><span class="token function">fileOverride</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 覆盖已生成文件</span>
                            <span class="token punctuation">.</span><span class="token function">outputDir</span><span class="token punctuation">(</span>outputDir<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 指定输出目录</span>
                <span class="token punctuation">}</span><span class="token punctuation">)</span>
                <span class="token comment">// --- 包配置(PackageConfig)</span>
                <span class="token punctuation">.</span><span class="token function">packageConfig</span><span class="token punctuation">(</span>builder <span class="token operator">-&gt;</span> <span class="token punctuation">{</span>
                    builder<span class="token punctuation">.</span><span class="token function">parent</span><span class="token punctuation">(</span>packageName<span class="token punctuation">)</span> <span class="token comment">// 设置父包名</span>
                            <span class="token punctuation">.</span><span class="token function">controller</span><span class="token punctuation">(</span>controllerDir<span class="token punctuation">)</span> <span class="token comment">// 设置 controller 的位置</span>
                            <span class="token punctuation">.</span><span class="token function">serviceImpl</span><span class="token punctuation">(</span>serviceImplDir<span class="token punctuation">)</span> <span class="token comment">// 设置 serviceImpl 的位置</span>
                            <span class="token punctuation">.</span><span class="token function">service</span><span class="token punctuation">(</span>serviceDir<span class="token punctuation">)</span> <span class="token comment">// 设置 service 的位置</span>
                            <span class="token punctuation">.</span><span class="token function">mapper</span><span class="token punctuation">(</span>mapperDir<span class="token punctuation">)</span><span class="token comment">// 设置 mapper 的位置</span>
                            <span class="token punctuation">.</span><span class="token function">xml</span><span class="token punctuation">(</span>mapperXmlDir<span class="token punctuation">)</span> <span class="token comment">// 设置 mapperxml 的位置</span>
                            <span class="token punctuation">.</span><span class="token function">entity</span><span class="token punctuation">(</span>entityDir<span class="token punctuation">)</span> <span class="token comment">// 设置 entity 的位置</span>
                            <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span><span class="token punctuation">)</span>
                <span class="token comment">// --- 策略配置(StrategyConfig)</span>
                <span class="token punctuation">.</span><span class="token function">strategyConfig</span><span class="token punctuation">(</span>builder <span class="token operator">-&gt;</span> <span class="token punctuation">{</span>
                    builder<span class="token punctuation">.</span><span class="token function">addInclude</span><span class="token punctuation">(</span>tableNames<span class="token punctuation">)</span>  <span class="token comment">// 给该表生成</span>
                            <span class="token punctuation">.</span><span class="token function">addTablePrefix</span><span class="token punctuation">(</span>tablePrefix<span class="token punctuation">)</span> <span class="token comment">// 设置过滤表前缀</span>
                            <span class="token comment">// 实体类配置</span>
                            <span class="token punctuation">.</span><span class="token function">entityBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                            <span class="token punctuation">.</span><span class="token function">enableLombok</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// entity 使用 lombok 注解</span>
                            <span class="token punctuation">.</span><span class="token function">idType</span><span class="token punctuation">(</span><span class="token constant">ASSIGN_ID</span><span class="token punctuation">)</span> <span class="token comment">// 设置自动生成主键类型的策略</span>
                            <span class="token punctuation">.</span><span class="token function">columnNaming</span><span class="token punctuation">(</span><span class="token class-name">NamingStrategy</span><span class="token punctuation">.</span>no_change<span class="token punctuation">)</span> <span class="token comment">// 驼峰: 数据库列名到实体类字段名的映射策略</span>
                            <span class="token comment">// 业务层配置</span>
                            <span class="token punctuation">.</span><span class="token function">serviceBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                            <span class="token comment">// 表现层配置</span>
                            <span class="token punctuation">.</span><span class="token function">controllerBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                            <span class="token punctuation">.</span><span class="token function">enableRestStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 开启生成 @RestController 控制器</span>
                            <span class="token comment">// 数据层配置</span>
                            <span class="token punctuation">.</span><span class="token function">mapperBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                            <span class="token punctuation">.</span><span class="token function">enableMapperAnnotation</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 开启 mapper 注解</span>
                <span class="token punctuation">}</span><span class="token punctuation">)</span>
                <span class="token comment">// --- 模板配置(TemplateConfig)</span>
                <span class="token punctuation">.</span><span class="token function">templateEngine</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">FreemarkerTemplateEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// 使用 Freemarker引擎模板，默认的是Velocity引擎模板</span>
                <span class="token punctuation">.</span><span class="token function">execute</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="mayun-代码生成器" tabindex="-1"><a class="header-anchor" href="#mayun-代码生成器" aria-hidden="true">#</a> MaYun 代码生成器</h3><blockquote><p>适用于 2022-码云科技有限公司</p></blockquote><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>apai</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>generator<span class="token punctuation">.</span></span><span class="token class-name">FastAutoGenerator</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>generator<span class="token punctuation">.</span>config<span class="token punctuation">.</span>rules<span class="token punctuation">.</span></span><span class="token class-name">NamingStrategy</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>generator<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span><span class="token class-name">FreemarkerTemplateEngine</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token keyword">static</span> <span class="token import static"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">IdType</span><span class="token punctuation">.</span><span class="token static">ASSIGN_ID</span></span><span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MyYunGenerate</span> <span class="token punctuation">{</span>

    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> <span class="token punctuation">{</span>

        <span class="token comment">// &lt;----- 代码生成器必须指定项 -----&gt;</span>
        <span class="token comment">// 生成的文件放置目录 必须以 &#39;\\ 或者 /&#39; 结尾 如: F:/paidaxing/</span>
        <span class="token class-name">String</span> outputDir <span class="token operator">=</span> <span class="token string">&quot;C:/paidaxing/&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">// 设置父包名 如: com.apai</span>
        <span class="token class-name">String</span> packageName <span class="token operator">=</span> <span class="token string">&quot;com.my.pin&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">// 数据库连接信息</span>
        <span class="token class-name">String</span> url <span class="token operator">=</span> <span class="token string">&quot;jdbc:mysql://192.168.1.88:3306/anming?serverTimezone=UTC&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> name <span class="token operator">=</span> <span class="token string">&quot;root&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> password <span class="token operator">=</span> <span class="token string">&quot;mayun1688&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">// 需要生成的表名 及 表前缀 &quot;user&quot;, &quot;category&quot;, &quot;jurisdiction&quot;, &quot;permission&quot;</span>
        <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> tableNames <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;produce_plan_record&quot;</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> tablePrefix <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;&quot;</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
        <span class="token comment">// 项目作者名称</span>
        <span class="token class-name">String</span> author <span class="token operator">=</span> <span class="token string">&quot;apai&quot;</span><span class="token punctuation">;</span>

        <span class="token comment">// 指定文件的位置 [. --&gt; /] 注意:开头不要是&quot;.&quot; 与类的包位置有关</span>
        <span class="token class-name">String</span> controllerDir <span class="token operator">=</span> <span class="token string">&quot;controller.admin&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> serviceImplDir <span class="token operator">=</span> <span class="token string">&quot;service.impl&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> serviceDir <span class="token operator">=</span> <span class="token string">&quot;service&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> mapperDir <span class="token operator">=</span> <span class="token string">&quot;mapper&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> mapperXmlDir <span class="token operator">=</span> <span class="token string">&quot;mapper&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">// 实体类备选: furniture plastic system</span>
        <span class="token class-name">String</span> entityDir <span class="token operator">=</span> <span class="token string">&quot;entity.system&quot;</span><span class="token punctuation">;</span>

        <span class="token comment">// 根据信息 开始生成代码</span>
        <span class="token class-name">FastAutoGenerator</span><span class="token punctuation">.</span><span class="token function">create</span><span class="token punctuation">(</span>url<span class="token punctuation">,</span> name<span class="token punctuation">,</span> password<span class="token punctuation">)</span>
                <span class="token comment">// --- 全局配置(GlobalConfig)</span>
                <span class="token punctuation">.</span><span class="token function">globalConfig</span><span class="token punctuation">(</span>builder <span class="token operator">-&gt;</span> <span class="token punctuation">{</span>
                    builder<span class="token punctuation">.</span><span class="token function">author</span><span class="token punctuation">(</span>author<span class="token punctuation">)</span> <span class="token comment">// 设置作者</span>
                            <span class="token punctuation">.</span><span class="token function">enableSwagger</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 开启 swagger 模式</span>
                            <span class="token punctuation">.</span><span class="token function">fileOverride</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 覆盖已生成文件</span>
                            <span class="token punctuation">.</span><span class="token function">outputDir</span><span class="token punctuation">(</span>outputDir<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 指定输出目录</span>
                <span class="token punctuation">}</span><span class="token punctuation">)</span>
                <span class="token comment">// --- 包配置(PackageConfig)</span>
                <span class="token punctuation">.</span><span class="token function">packageConfig</span><span class="token punctuation">(</span>builder <span class="token operator">-&gt;</span> <span class="token punctuation">{</span>
                    builder<span class="token punctuation">.</span><span class="token function">parent</span><span class="token punctuation">(</span>packageName<span class="token punctuation">)</span> <span class="token comment">// 设置父包名</span>
                            <span class="token punctuation">.</span><span class="token function">controller</span><span class="token punctuation">(</span>controllerDir<span class="token punctuation">)</span> <span class="token comment">// 设置 controller 的位置</span>
                            <span class="token punctuation">.</span><span class="token function">serviceImpl</span><span class="token punctuation">(</span>serviceImplDir<span class="token punctuation">)</span> <span class="token comment">// 设置 serviceImpl 的位置</span>
                            <span class="token punctuation">.</span><span class="token function">service</span><span class="token punctuation">(</span>serviceDir<span class="token punctuation">)</span> <span class="token comment">// 设置 service 的位置</span>
                            <span class="token punctuation">.</span><span class="token function">mapper</span><span class="token punctuation">(</span>mapperDir<span class="token punctuation">)</span><span class="token comment">// 设置 mapper 的位置</span>
                            <span class="token punctuation">.</span><span class="token function">xml</span><span class="token punctuation">(</span>mapperXmlDir<span class="token punctuation">)</span> <span class="token comment">// 设置 mapperxml 的位置</span>
                            <span class="token punctuation">.</span><span class="token function">entity</span><span class="token punctuation">(</span>entityDir<span class="token punctuation">)</span> <span class="token comment">// 设置 entity 的位置</span>
                            <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span><span class="token punctuation">)</span>
                <span class="token comment">// --- 策略配置(StrategyConfig)</span>
                <span class="token punctuation">.</span><span class="token function">strategyConfig</span><span class="token punctuation">(</span>builder <span class="token operator">-&gt;</span> <span class="token punctuation">{</span>
                    builder<span class="token punctuation">.</span><span class="token function">addInclude</span><span class="token punctuation">(</span>tableNames<span class="token punctuation">)</span>  <span class="token comment">// 给该表生成</span>
                            <span class="token punctuation">.</span><span class="token function">addTablePrefix</span><span class="token punctuation">(</span>tablePrefix<span class="token punctuation">)</span> <span class="token comment">// 设置过滤表前缀</span>
                            <span class="token comment">// 实体类配置</span>
                            <span class="token punctuation">.</span><span class="token function">entityBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                            <span class="token punctuation">.</span><span class="token function">enableLombok</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// entity 使用 lombok 注解</span>
                            <span class="token punctuation">.</span><span class="token function">idType</span><span class="token punctuation">(</span><span class="token constant">ASSIGN_ID</span><span class="token punctuation">)</span> <span class="token comment">// 设置自动生成主键类型的策略</span>
                            <span class="token punctuation">.</span><span class="token function">columnNaming</span><span class="token punctuation">(</span><span class="token class-name">NamingStrategy</span><span class="token punctuation">.</span>no_change<span class="token punctuation">)</span> <span class="token comment">// 驼峰: 数据库列名到实体类字段名的映射策略</span>
                            <span class="token comment">// 业务层配置</span>
                            <span class="token punctuation">.</span><span class="token function">serviceBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                            <span class="token comment">// 表现层配置</span>
                            <span class="token punctuation">.</span><span class="token function">controllerBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                            <span class="token punctuation">.</span><span class="token function">enableRestStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 开启生成 @RestController 控制器</span>
                            <span class="token comment">// 数据层配置</span>
                            <span class="token punctuation">.</span><span class="token function">mapperBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                            <span class="token punctuation">.</span><span class="token function">enableMapperAnnotation</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 开启 mapper 注解</span>
                <span class="token punctuation">}</span><span class="token punctuation">)</span>
                <span class="token comment">// --- 模板配置(TemplateConfig)</span>
                <span class="token punctuation">.</span><span class="token function">templateEngine</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">FreemarkerTemplateEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// 使用 Freemarker引擎模板，默认的是Velocity引擎模板</span>
                <span class="token punctuation">.</span><span class="token function">execute</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

<span class="token punctuation">}</span>

</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="easycode-代码生成器" tabindex="-1"><a class="header-anchor" href="#easycode-代码生成器" aria-hidden="true">#</a> EasyCode 代码生成器</h2><ul><li>EasyCode <a href="https://gitee.com/makejava/EasyCode/wikis/pages" target="_blank" rel="noopener noreferrer">官方使用文档<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a></li><li>Velocity <a href="https://www.cnblogs.com/yangzhinian/p/4885973.html" target="_blank" rel="noopener noreferrer">模板引擎语法 <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a></li></ul><h3 id="下载插件" tabindex="-1"><a class="header-anchor" href="#下载插件" aria-hidden="true">#</a> 下载插件</h3><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230511164805752.png" alt="image-20230511164805752"></p><h3 id="生成代码" tabindex="-1"><a class="header-anchor" href="#生成代码" aria-hidden="true">#</a> 生成代码</h3><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230512155522558.png" alt="image-20230512155522558"></p><h3 id="自定义模板文件" tabindex="-1"><a class="header-anchor" href="#自定义模板文件" aria-hidden="true">#</a> 自定义模板文件</h3><div class="language-json line-numbers-mode" data-ext="json"><pre class="language-json"><code><span class="token punctuation">{</span>
  <span class="token property">&quot;author&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Lu-Apai: 菩萨保佑 BUG全无&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;version&quot;</span><span class="token operator">:</span> <span class="token string">&quot;1.2.8&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;userSecure&quot;</span><span class="token operator">:</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;currTypeMapperGroupName&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Default&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;currTemplateGroupName&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Apai-MyBatis-Plus&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;currColumnConfigGroupName&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Default&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;currGlobalConfigGroupName&quot;</span><span class="token operator">:</span> <span class="token string">&quot;默认&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;类型映射器&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token property">&quot;template&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token property">&quot;Apai-MyBatis-Plus&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span>
      <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Apai-MyBatis-Plus&quot;</span><span class="token punctuation">,</span>
      <span class="token property">&quot;elementList&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span>
        <span class="token punctuation">{</span>
          <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Controller.java.vm&quot;</span><span class="token punctuation">,</span>
          <span class="token property">&quot;code&quot;</span><span class="token operator">:</span> <span class="token string">&quot;##导入宏定义\n$!{define.vm}\n\n##设置表后缀（宏定义）\n#setTableSuffix(\&quot;Controller\&quot;)\n\n##保存文件（宏定义）\n#save(\&quot;/controller\&quot;, \&quot;Controller.java\&quot;)\n\n##包路径（宏定义）\n#setPackageSuffix(\&quot;controller\&quot;)\n\n##定义服务名 #set($变量名 = $!文档属性) 调用: $!{变量名}\n#set($serviceName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), \&quot;Service\&quot;))\n##定义实体对象名 (大写)\n#set($entity = $!tool.firstUpperCase($!tableInfo.name))\n##定义实体对象名 (小写)\n#set($entityName = $!tool.firstLowerCase($!tableInfo.name))\n##定义实体VO对象名\n#set($entityVo = \&quot;$!{tableInfo.name}Vo\&quot;)\n##定义实体对象名 (小写)\n#set($entityVoName = $!tool.firstLowerCase(\&quot;$!{tableInfo.name}Vo\&quot;))\n\nimport com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;\nimport com.baomidou.mybatisplus.extension.api.ApiController;\nimport com.baomidou.mybatisplus.extension.api.R;\nimport com.baomidou.mybatisplus.extension.plugins.pagination.Page;\nimport $!{tableInfo.savePackageName}.entity.$!tableInfo.name;\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.web.bind.annotation.*;\n\nimport javax.annotation.Resource;\nimport java.io.Serializable;\nimport java.util.List;\n\n##表注释（宏定义）\n#tableComment(\&quot;表控制层\&quot;)\n\n@Api(tags = {\&quot;$tableInfo.comment\&quot;})\n@RestController\n@RequestMapping(\&quot;/$entityName\&quot;)\npublic class $!{tableName} {\n    \n\n    /**\n     * 业务层对象\n     */\n    @Resource\n    private $!{tableInfo.name}Service $!{serviceName};\n    \n    \n    @PostMapping(\&quot;/list$!{entity}\&quot;)\n    @ApiOperation(\&quot;获取所有数据\&quot;)\n    public void list$!{entity}(@RequestBody $!{entityVo} $!{entityVoName}) {\n        \n    }\n    \n    @PostMapping(\&quot;/save$!{entity}\&quot;)\n    @ApiOperation(\&quot;新增\&quot;)\n    public void save$!{entity}(@RequestBody $!{entityVo} $!{entityVoName}) {\n        \n    }\n\n    @PostMapping(\&quot;/update$!{entity}\&quot;)\n    @ApiOperation(\&quot;修改\&quot;)\n    public void update$!{entity}(@RequestBody $!{entityVo} $!{entityVoName}) {\n       \n    }\n    \n    @PostMapping(\&quot;/delete$!{entity}ById/{id}\&quot;)\n    @ApiOperation(\&quot;根据id删除对象\&quot;)\n    public void delete$!{entity}ById(@PathVariable(\&quot;id\&quot;) Integer id) {\n        \n    }\n\n    @PostMapping(\&quot;get$!{entity}ById/{id}\&quot;)\n    @ApiOperation(\&quot;根据id查询对象数据\&quot;)\n    public void get$!{entity}ById(@PathVariable(\&quot;id\&quot;) Integer id) {\n       \n    }\n    \n}&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Service.java.vm&quot;</span><span class="token punctuation">,</span>
          <span class="token property">&quot;code&quot;</span><span class="token operator">:</span> <span class="token string">&quot;##导入宏定义\n$!{define.vm}\n\n##设置表后缀（宏定义）\n#setTableSuffix(\&quot;Service\&quot;)\n\n##保存文件（宏定义）\n#save(\&quot;/service\&quot;, \&quot;Service.java\&quot;)\n\n##包路径（宏定义）\n#setPackageSuffix(\&quot;service\&quot;)\n\n##定义实体对象名 (大写)\n#set($entity = $!tool.firstUpperCase($!tableInfo.name))\n##定义实体对象名 (小写)\n#set($entityName = $!tool.firstLowerCase($!tableInfo.name))\n##定义实体VO对象名\n#set($entityVo = \&quot;$!{tableInfo.name}Vo\&quot;)\n##定义实体对象名 (小写)\n#set($entityVoName = $!tool.firstLowerCase(\&quot;$!{tableInfo.name}Vo\&quot;))\n\nimport com.baomidou.mybatisplus.extension.service.IService;\nimport com.baomidou.mybatisplus.extension.plugins.pagination.Page;\nimport $!{tableInfo.savePackageName}.entity.$!tableInfo.name;\n\n##表注释（宏定义）\n#tableComment(\&quot;表服务接口\&quot;)\npublic interface $!{tableName} extends IService&lt;$!tableInfo.name&gt; {\n    \n}\n&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;ServiceImpl.java.vm&quot;</span><span class="token punctuation">,</span>
          <span class="token property">&quot;code&quot;</span><span class="token operator">:</span> <span class="token string">&quot;##导入宏定义\n$!{define.vm}\n\n##设置表后缀（宏定义）\n#setTableSuffix(\&quot;ServiceImpl\&quot;)\n\n##保存文件（宏定义）\n#save(\&quot;/service/impl\&quot;, \&quot;ServiceImpl.java\&quot;)\n\n##包路径（宏定义）\n#setPackageSuffix(\&quot;service.impl\&quot;)\n\n##定义服务名\n#set($mapperName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), \&quot;Mapper\&quot;))\n##定义实体对象名 (大写)\n#set($entity = $!tool.firstUpperCase($!tableInfo.name))\n##定义实体对象名 (小写)\n#set($entityName = $!tool.firstLowerCase($!tableInfo.name))\n##定义实体VO对象名\n#set($entityVo = \&quot;$!{tableInfo.name}Vo\&quot;)\n##定义实体对象名 (小写)\n#set($entityVoName = $!tool.firstLowerCase(\&quot;$!{tableInfo.name}Vo\&quot;))\n\n\nimport com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;\nimport $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao;\nimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.stereotype.Service;\n\n##表注释（宏定义）\n#tableComment(\&quot;表服务实现类\&quot;)\n@Service\npublic class $!{tableName} extends ServiceImpl&lt;$!{tableInfo.name}Mapper, $!{tableInfo.name}&gt; implements $!{tableInfo.name}Service {\n\n    @Autowired\n    private $!{tableInfo.name}Mapper $!{mapperName};\n\n}\n&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Mapper.java.vm&quot;</span><span class="token punctuation">,</span>
          <span class="token property">&quot;code&quot;</span><span class="token operator">:</span> <span class="token string">&quot;##导入宏定义\n$!{define.vm}\n\n##设置表后缀（宏定义）\n#setTableSuffix(\&quot;Mapper\&quot;)\n\n##保存文件（宏定义）\n#save(\&quot;/mapper\&quot;, \&quot;Mapper.java\&quot;)\n\n##包路径（宏定义）\n#setPackageSuffix(\&quot;mapper\&quot;)\n\n##定义实体对象名 (大写)\n#set($entity = $!tool.firstUpperCase($!tableInfo.name))\n##定义实体对象名 (小写)\n#set($entityName = $!tool.firstLowerCase($!tableInfo.name))\n##定义实体VO对象名\n#set($entityVo = \&quot;$!{tableInfo.name}Vo\&quot;)\n##定义实体对象名 (小写)\n#set($entityVoName = $!tool.firstLowerCase(\&quot;$!{tableInfo.name}Vo\&quot;))\n\nimport java.util.List;\n\nimport com.baomidou.mybatisplus.core.mapper.BaseMapper;\nimport com.baomidou.mybatisplus.extension.plugins.pagination.Page;\nimport org.apache.ibatis.annotations.Param;\nimport $!{tableInfo.savePackageName}.entity.$!tableInfo.name;\n\n##表注释（宏定义）\n#tableComment(\&quot;表数据库访问层\&quot;)\n\n@Mapper\npublic interface $!{tableName} extends BaseMapper&lt;$!tableInfo.name&gt; {\n\n    /**\n    * 批量新增数据（MyBatis原生foreach方法）\n    *\n    * @param entities List&lt;$!{tableInfo.name}&gt; 实例对象列表\n    * @return 影响行数\n    */\n    int batchSave$!{entity}(@Param(\&quot;entities\&quot;) List&lt;$!{tableInfo.name}&gt; entities);\n\n\n}\n&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Mapper.xml.vm&quot;</span><span class="token punctuation">,</span>
          <span class="token property">&quot;code&quot;</span><span class="token operator">:</span> <span class="token string">&quot;##引入mybatis支持\n$!{mybatisSupport.vm}\n\n##设置保存名称与保存位置\n$!callback.setFileName($tool.append($!{tableInfo.name}, \&quot;Mapper.xml\&quot;))\n$!callback.setSavePath($tool.append($modulePath, \&quot;/src/main/resources/mapper\&quot;))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n    #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n##定义实体对象名 (大写)\n#set($entity = $!tool.firstUpperCase($!tableInfo.name))\n##定义实体对象名 (小写)\n#set($entityName = $!tool.firstLowerCase($!tableInfo.name))\n##定义实体VO对象名\n#set($entityVo = \&quot;$!{tableInfo.name}Vo\&quot;)\n##定义实体对象名 (小写)\n#set($entityVoName = $!tool.firstLowerCase(\&quot;$!{tableInfo.name}Vo\&quot;))\n\n\n&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt;\n&lt;!DOCTYPE mapper PUBLIC \&quot;-//mybatis.org//DTD Mapper 3.0//EN\&quot; \&quot;http://mybatis.org/dtd/mybatis-3-mapper.dtd\&quot;&gt;\n&lt;mapper namespace=\&quot;$!{tableInfo.savePackageName}.mapper.$!{tableInfo.name}Mapper\&quot;&gt;\n   \n    &lt;!-- 批量插入 --&gt;\n    &lt;insert id=\&quot;batchSave$!{entity}\&quot; keyProperty=\&quot;$!pk.name\&quot; useGeneratedKeys=\&quot;true\&quot;&gt;\n        insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)\n        values\n        &lt;foreach collection=\&quot;entities\&quot; item=\&quot;entity\&quot; separator=\&quot;,\&quot;&gt;\n        (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end)\n        &lt;/foreach&gt;\n    &lt;/insert&gt;\n    \n    &lt;!-- 查询 表字段 --&gt;\n    &lt;sql id=\&quot;select\&quot;&gt;#foreach($pk in $tableInfo.fullColumn)#if(!$foreach.last)\n\n        a.$tool.hump2Underline($pk.name) AS $!{pk.name},#else\n        \n        a.$tool.hump2Underline($pk.name) AS $!{pk.name}\n   #end#end\n&lt;/sql&gt;\n\n    &lt;!-- 表字段 动态条件 --&gt;\n    &lt;sql id=\&quot;where\&quot;&gt;\n#foreach($column in $tableInfo.fullColumn) \n        &lt;if test=\&quot;entity.$!{column.name}#if($velocityHasNext)#end != null and entity.$!{column.name}#if($velocityHasNext)#end != &#39;&#39;\&quot;&gt;\n            and a.$!column.obj.name#if($velocityHasNext)#end = #{entity.$!{column.name}}#if($velocityHasNext)#end           \n        \n        &lt;/if&gt;\n#end\n    &lt;/sql&gt;\n\n&lt;/mapper&gt;\n&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;entity.java.vm&quot;</span><span class="token punctuation">,</span>
          <span class="token property">&quot;code&quot;</span><span class="token operator">:</span> <span class="token string">&quot;##导入宏定义\n$!{define.vm}\n\n##保存文件（宏定义）#save(\&quot;生成有组织路径则加在这 /文件位置\&quot;, \&quot;entity + 自定义后缀.java\&quot;)\n### 例如:save(\&quot;\\com\\my\\pin\\entity\\sanitary\&quot;, \&quot;.java\&quot;)\n#save(\&quot;/entity\&quot;, \&quot;.java\&quot;)\n\n##包路径（宏定义）例如: #setPackageSuffix(\&quot;生成有组织路径则加在这. entity.sanitary\&quot;)\n#setPackageSuffix(\&quot;entity\&quot;)\n\n##自动导入包（全局变量）\n$!{autoImport.vm}\nimport com.baomidou.mybatisplus.extension.activerecord.Model;\nimport java.io.Serializable;\n\n##表注释（宏定义）\n#tableComment(\&quot;表实体类\&quot;)\n \n@Data\n@TableName(\&quot;$!{tool.firstLowerCase($!{tool.hump2Underline($!{tableInfo.name})})}\&quot;)\n@ApiModel(value = \&quot;$tableInfo.name 对象\&quot;, description = \&quot;\&quot;)\npublic class $!{tableInfo.name} implements Serializable  {\n\n    private static final long serialVersionUID = 1L;\n\n#foreach($pk in $tableInfo.pkColumn)\n    @ApiModelProperty(\&quot;$pk.comment\&quot;)\n    @TableId(value = \&quot;$tool.hump2Underline(\&quot;$pk.name\&quot;)\&quot;, type = IdType.AUTO)\n    private $!{tool.getClsNameByFullName($pk.type)} $!{pk.name};\n#end\n\n#foreach($ot in $tableInfo.otherColumn)\n    @ApiModelProperty(\&quot;$ot.comment\&quot;)\n    @TableField(value = \&quot;$tool.hump2Underline($ot.name)\&quot;)\n    private $!{tool.getClsNameByFullName($ot.type)} $!{ot.name};\n#end\n}&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;entityVo.java.vm&quot;</span><span class="token punctuation">,</span>
          <span class="token property">&quot;code&quot;</span><span class="token operator">:</span> <span class="token string">&quot;##导入宏定义\n$!{define.vm}\n\n##保存文件（宏定义）\n#save(\&quot;/vo\&quot;, \&quot;Vo.java\&quot;)\n\n##包路径（宏定义）\n#setPackageSuffix(\&quot;vo\&quot;)\n\n##自动导入包（全局变量）\n$!{autoImport.vm}\n\n##表注释（宏定义）\n#tableComment(\&quot;表实体Vo类\&quot;)\n \n@Data\n@ApiModel(value = \&quot;$tableInfo.name Vo对象\&quot;, description = \&quot;\&quot;)\npublic class $!{tableInfo.name}Vo extends $!{tableInfo.name}  {\n\n}&quot;</span>
        <span class="token punctuation">}</span>
      <span class="token punctuation">]</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token property">&quot;MaYun-Mybatis-plus&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span>
      <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;MaYun-Mybatis-plus&quot;</span><span class="token punctuation">,</span>
      <span class="token property">&quot;elementList&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span>
        <span class="token punctuation">{</span>
          <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Controller.java.vm&quot;</span><span class="token punctuation">,</span>
          <span class="token property">&quot;code&quot;</span><span class="token operator">:</span> <span class="token string">&quot;##导入宏定义\n$!{define.vm}\n\n##设置表后缀（宏定义）\n#setTableSuffix(\&quot;Controller\&quot;)\n\n##保存文件（宏定义）\n#save(\&quot;/controller\&quot;, \&quot;Controller.java\&quot;)\n\n##包路径（宏定义）\n#setPackageSuffix(\&quot;controller\&quot;)\n\n##定义服务名 #set($变量名 = $!文档属性) 调用: $!{变量名}\n#set($serviceName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), \&quot;Service\&quot;))\n### 自定义全局变量 \n$!{My-mayun.vm}\n### 实体类 和 vo类的导包\n$!{ie}\n$!{iev}\nimport com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;\nimport com.baomidou.mybatisplus.extension.api.ApiController;\nimport com.baomidou.mybatisplus.extension.plugins.pagination.Page;\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.web.bind.annotation.*;\n\nimport javax.annotation.Resource;\nimport java.io.Serializable;\nimport java.util.List;\n\n##表注释（宏定义）\n#tableComment(\&quot;表控制层\&quot;)\n\n@Api(tags = {\&quot;$tableInfo.comment\&quot;})\n@RestController\n@RequestMapping(\&quot;/$entityName\&quot;)\npublic class $!{tableName} {\n    \n\n    /**\n     * 业务层对象\n     */\n    @Resource\n    private $!{tableInfo.name}Service $!{serviceName};\n    \n    \n    @PostMapping(\&quot;/list$!{entity}\&quot;)\n    @ApiOperation(\&quot;获取所有数据\&quot;)\n    public TableR list$!{entity}(@RequestBody $!{entityVo} $!{entityVoName}) {\n        // 分页对象 数据集合 总条数 合计\n        Page&lt;$!{entityVo}&gt; page = new Page&lt;&gt;($!{entityVoName}.getPage(), $!{entityVoName}.getLimit());\n        List&lt;$!{entityVo}&gt; list = $!{serviceName}.list$!{entity}(page, $!{entityVoName});\n        Long number = page.getTotal();\n        // $!{entityVo} total = $!{serviceName}.total$!{entity}($!{entityVoName});\n        return TableR.success(list, number);\n    }\n    \n    @PostMapping(\&quot;/save$!{entity}\&quot;)\n    @ApiOperation(\&quot;新增\&quot;)\n    public R save$!{entity}(@RequestBody $!{entityVo} $!{entityVoName}) {\n        return $!{serviceName}.save$!{entity}($!{entityVoName});\n    }\n\n    @PostMapping(\&quot;/update$!{entity}\&quot;)\n    @ApiOperation(\&quot;修改\&quot;)\n    public R update$!{entity}(@RequestBody $!{entityVo} $!{entityVoName}) {\n        return $!{serviceName}.update$!{entity}($!{entityVoName});\n    }\n    \n    @PostMapping(\&quot;/delete$!{entity}ById/{id}\&quot;)\n    @ApiOperation(\&quot;根据id删除对象\&quot;)\n    public R delete$!{entity}ById(@PathVariable(\&quot;id\&quot;) Integer id) {\n        return $!{serviceName}.delete$!{entity}ById(id);\n    }\n\n    @PostMapping(\&quot;get$!{entity}ById/{id}\&quot;)\n    @ApiOperation(\&quot;根据id查询对象数据\&quot;)\n    public R get$!{entity}ById(@PathVariable(\&quot;id\&quot;) Integer id) {\n        return R.success($!{serviceName}.get$!{entity}ById(id));\n    }\n    \n    @PostMapping(\&quot;list$!{entity}Choice\&quot;)\n    @ApiOperation(value = \&quot;下拉框\&quot;)\n    public R list$!{entity}Choice() {\n        return R.success($!{serviceName}.list$!{entity}Choice());\n    }\n    \n    @PostMapping(\&quot;exportExcel$!{entity}\&quot;)\n    @ApiOperation(\&quot;导出Excel\&quot;)\n    public void exportExcel$!{entity}(@RequestBody $!{entityVo} $!{entityVoName}, HttpServletResponse response){\n        Page&lt;$!{entityVo}&gt; page = new Page&lt;&gt;(1,Integer.MAX_VALUE);\n        List&lt;$!{entityVo}&gt; list = $!{serviceName}.list$!{entity}(page, $!{entityVoName});\n        String fileName = \&quot;$!{tableInfo.comment}\&quot;;\n        EasyPoiExcelUtils.exportExcel(list, $!{entityVo}.class, \&quot;$!{tableInfo.comment}\&quot; + DateUtils.farmtDateMin() + \&quot;.xlsx\&quot;, response, new ExportParams(fileName, \&quot;sheet1\&quot;, ExcelType.XSSF));\n    }\n    \n    @PostMapping(value = \&quot;importExcel$!{entity}\&quot;)\n    @ApiOperation(\&quot;导入Excel\&quot;)\n    public R importExcel$!{entity}(MultipartFile file) throws Exception {\n        if (Objects.equals(file,null)){\n            return R.error(\&quot;请添加附件\&quot;);\n        }else {\n            return $!{serviceName}.importExcel$!{entity}(file);\n        }\n    }\n}&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Service.java.vm&quot;</span><span class="token punctuation">,</span>
          <span class="token property">&quot;code&quot;</span><span class="token operator">:</span> <span class="token string">&quot;##导入宏定义\n$!{define.vm}\n\n##设置表后缀（宏定义）\n#setTableSuffix(\&quot;Service\&quot;)\n\n##保存文件（宏定义）\n#save(\&quot;/service\&quot;, \&quot;Service.java\&quot;)\n\n##包路径（宏定义）\n#setPackageSuffix(\&quot;service\&quot;)\n\nimport com.my.pin.result.R;\n### 自定义全局变量 \n$!{My-mayun.vm}\n### 实体类 和 vo类的导包\n$!{ie}\n$!{iev}\nimport com.baomidou.mybatisplus.extension.service.IService;\nimport com.baomidou.mybatisplus.extension.plugins.pagination.Page;\nimport java.util.List;\n\n##表注释（宏定义）\n#tableComment(\&quot;表服务接口\&quot;)\npublic interface $!{tableName} extends IService&lt;$!tableInfo.name&gt; {\n\n /**\n     * 获取主表所有数据\n     * @param page\n     * @param $!{entityVoName}\n     * @return\n     */\n    List&lt;$!{entityVo}&gt; list$!{entity}(Page&lt;$!{entityVo}&gt; page, $!{entityVo} $!{entityVoName});\n\n    /**\n     * 保存\n     * @param $!{entityVoName}\n     * @return\n     */\n    R save$!{entity}($!{entityVo} $!{entityVoName});\n\n    /**\n     * 修改\n     * @param $!{entityVoName}\n     * @return\n     */\n    R update$!{entity}($!{entityVo} $!{entityVoName});\n\n    /**\n     * 删除\n     * @param id\n     * @return\n     */\n    R delete$!{entity}ById(Integer id);\n\n    /**\n     * 根据id获取数据\n     * @param id\n     * @return\n     */\n    $!{entityVo} get$!{entity}ById(Integer id);\n    \n    /**\n     * 获取下拉\n     * @return\n     */\n    List&lt;$!{entity}&gt; list$!{entity}Choice();\n    \n     /**\n     * 读取Excel数据导入数据库\n     * @param file\n     * @return\n     * @throws Exception\n     */\n    R importExcel$!{entity}(MultipartFile file) throws Exception;\n    \n}&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;ServiceImpl.java.vm&quot;</span><span class="token punctuation">,</span>
          <span class="token property">&quot;code&quot;</span><span class="token operator">:</span> <span class="token string">&quot;##导入宏定义\n$!{define.vm}\n\n##设置表后缀（宏定义）\n#setTableSuffix(\&quot;ServiceImpl\&quot;)\n\n##保存文件（宏定义）\n#save(\&quot;/service/impl\&quot;, \&quot;ServiceImpl.java\&quot;)\n\n##包路径（宏定义）\n#setPackageSuffix(\&quot;service.impl\&quot;)\n\n##定义服务名\n#set($mapperName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), \&quot;Mapper\&quot;))\n### 自定义全局变量 \n$!{My-mayun.vm}\n### 实体类 和 vo类的导包\n$!{ie}\n$!{iev}\nimport com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;\nimport $!{tableInfo.savePackageName}.mapper.$!{tableInfo.name}Mapper;\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.stereotype.Service;\nimport org.springframework.beans.BeanUtils;\n\n##表注释（宏定义）\n#tableComment(\&quot;表服务实现类\&quot;)\n@Service\npublic class $!{tableName} extends ServiceImpl&lt;$!{tableInfo.name}Mapper, $!{tableInfo.name}&gt; implements $!{tableInfo.name}Service {\n\n    @Autowired\n    private $!{tableInfo.name}Mapper $!{mapperName};\n\n    @Override\n    public List&lt;$!{entityVo}&gt; list$!{entity}(Page&lt;$!{entityVo}&gt; page, $!{entityVo} $!{entityVoName}) {\n        return baseMapper.list$!{entity}(page, $!{entityVoName});\n    }\n\n    @Override\n    public R save$!{entity}($!{entityVo} $!{entityVoName}) {\n        int insert = baseMapper.insert($!{entityVoName});\n        return R.success();\n    }\n\n    @Override\n    public R update$!{entity}($!{entityVo} $!{entityVoName}) {\n        // 修改数据\n        int update = baseMapper.updateById($!{entityVoName});\n        return R.success();\n    }\n\n    @Override\n    public R delete$!{entity}ById(Integer id) {\n        int i = baseMapper.deleteById(id);\n        return R.success();\n    }\n\n    @Override\n    public $!{entityVo} get$!{entity}ById(Integer id) {\n        $!{entity} $!{entityName} = baseMapper.selectById(id);\n        $!{entityVo} $!{entityVoName} = new $!{entityVo}();\n        BeanUtils.copyProperties($!{entityName}, $!{entityVoName});\n        return $!{entityVoName};\n    }\n    \n    @Override\n    public List&lt;$!{entity}&gt; list$!{entity}Choice() {\n        QueryWrapper&lt;$!{entity}&gt; where = new QueryWrapper&lt;&gt;();\n        // 查询条件省略...\n        return baseMapper.selectList(where);\n    }\n    \n     @Override\n    public R importExcel$!{entity}(MultipartFile file) throws Exception {\n        // 步骤按照其他参考...\n        return R.success();\n    }\n   \n}&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Mapper.java.vm&quot;</span><span class="token punctuation">,</span>
          <span class="token property">&quot;code&quot;</span><span class="token operator">:</span> <span class="token string">&quot;##导入宏定义\n$!{define.vm}\n\n##设置表后缀（宏定义）\n#setTableSuffix(\&quot;Mapper\&quot;)\n\n##保存文件（宏定义）\n#save(\&quot;/mapper\&quot;, \&quot;Mapper.java\&quot;)\n\n##包路径（宏定义）\n#setPackageSuffix(\&quot;mapper\&quot;)\n\n### 自定义全局变量 \n$!{My-mayun.vm}\n### 实体类 和 vo类的导包\n$!{ie}\n$!{iev}\n\nimport com.baomidou.mybatisplus.core.mapper.BaseMapper;\nimport com.baomidou.mybatisplus.extension.plugins.pagination.Page;\nimport org.apache.ibatis.annotations.Param;\nimport java.util.List;\n\n### 实体类 vo类 导包路径\n$!{Myentity.vm}\n\n##表注释（宏定义）\n#tableComment(\&quot;表数据库访问层\&quot;)\n\n@Mapper\npublic interface $!{tableName} extends BaseMapper&lt;$!tableInfo.name&gt; {\n\n    /**\n     * 获取主表所有数据\n     * @param page\n     * @param $!{entityVoName}\n     * @return\n     */\n    List&lt;$!{entityVo}&gt; list$!{entity}(Page&lt;$!{entityVo}&gt; page, @Param(\&quot;entity\&quot;) $!{entityVo} $!{entityVoName});\n\n    /**\n    * 批量新增数据（MyBatis原生foreach方法）\n    *\n    * @param entities List&lt;$!{tableInfo.name}&gt; 实例对象列表\n    * @return 影响行数\n    */\n    int batchSave$!{entity}(@Param(\&quot;entities\&quot;) List&lt;$!{tableInfo.name}&gt; entities);\n\n}&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Mapper.xml.vm&quot;</span><span class="token punctuation">,</span>
          <span class="token property">&quot;code&quot;</span><span class="token operator">:</span> <span class="token string">&quot;##引入mybatis支持\n$!{mybatisSupport.vm}\n\n##设置保存名称与保存位置\n$!callback.setFileName($tool.append($!{tableInfo.name}, \&quot;Mapper.xml\&quot;))\n$!callback.setSavePath($tool.append($modulePath, \&quot;/src/main/resources/mapper\&quot;))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n    #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n### 自定义全局变量 \n$!{My-mayun.vm}\n\n\n&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt;\n&lt;!DOCTYPE mapper PUBLIC \&quot;-//mybatis.org//DTD Mapper 3.0//EN\&quot; \&quot;http://mybatis.org/dtd/mybatis-3-mapper.dtd\&quot;&gt;\n&lt;mapper namespace=\&quot;$!{tableInfo.savePackageName}.mapper.$!{tableInfo.name}Mapper\&quot;&gt;\n\n    &lt;!-- 查询列表 --&gt;\n    &lt;select id=\&quot;list$!{entity}\&quot; resultType=\&quot;$!{mev}\&quot;&gt;\n        SELECT\n            &lt;include refid=\&quot;select\&quot;/&gt;\n        FROM\n            $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name} a\n        WHERE a.status = 1\n            &lt;include refid=\&quot;where\&quot;/&gt;\n        order by a.create_time desc\n    &lt;/select&gt;\n   \n    &lt;!-- 批量插入 --&gt;\n    &lt;insert id=\&quot;batchSave$!{entity}\&quot; keyProperty=\&quot;$!pk.name\&quot; useGeneratedKeys=\&quot;true\&quot;&gt;\n        insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)\n        values\n        &lt;foreach collection=\&quot;entities\&quot; item=\&quot;entity\&quot; separator=\&quot;,\&quot;&gt;\n        (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end)\n        &lt;/foreach&gt;\n    &lt;/insert&gt;\n\n    &lt;!-- 查询 表字段 --&gt;\n    &lt;sql id=\&quot;select\&quot;&gt;#foreach($pk in $tableInfo.fullColumn)#if(!$foreach.last)\n\n        a.$tool.hump2Underline($pk.name) AS $!{pk.name},#else\n        \n        a.$tool.hump2Underline($pk.name) AS $!{pk.name}\n   #end#end\n&lt;/sql&gt;\n\n    &lt;!-- 表字段 动态条件 --&gt;\n    &lt;sql id=\&quot;where\&quot;&gt;\n#foreach($column in $tableInfo.fullColumn) \n        &lt;if test=\&quot;entity.$!{column.name}#if($velocityHasNext)#end != null and entity.$!{column.name}#if($velocityHasNext)#end != &#39;&#39;\&quot;&gt;\n            and a.$!column.obj.name#if($velocityHasNext)#end = #{entity.$!{column.name}}#if($velocityHasNext)#end           \n        \n        &lt;/if&gt;\n#end\n    &lt;/sql&gt;\n\n&lt;/mapper&gt;&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;entity.java.vm&quot;</span><span class="token punctuation">,</span>
          <span class="token property">&quot;code&quot;</span><span class="token operator">:</span> <span class="token string">&quot;##导入宏定义\n$!{define.vm}\n### 自定义全局变量 \n$!{My-mayun.vm}\n\n##保存文件（宏定义）#save(\&quot;生成有组织路径则加在这/文件位置\&quot;, \&quot;entity + 自定义后缀.java\&quot;)\n#save($!{entitylujing}, \&quot;.java\&quot;)\n\n##包路径（宏定义）\n#setPackageSuffix(\&quot;entity.$!{mokuai}\&quot;)\n\n##自动导入包（全局变量）\n$!{autoImport.vm}\nimport com.baomidou.mybatisplus.extension.activerecord.Model;\nimport java.io.Serializable;\n\n##表注释（宏定义）\n#tableComment(\&quot;表实体类\&quot;)\n \n@Data\n@TableName(\&quot;$!{tool.firstLowerCase($!{tool.hump2Underline($!{tableInfo.name})})}\&quot;)\n@ApiModel(value = \&quot;$tableInfo.name 对象\&quot;, description = \&quot;\&quot;)\npublic class $!{tableInfo.name} extends BaseEntity implements Serializable  {\n\n#foreach($pk in $tableInfo.pkColumn)\n    @ApiModelProperty(\&quot;$pk.comment\&quot;)\n    @TableId(value = \&quot;$tool.hump2Underline(\&quot;$pk.name\&quot;)\&quot;)\n    private $!{tool.getClsNameByFullName($pk.type)} $!{pk.name};\n#end\n\n#foreach($ot in $tableInfo.otherColumn)\n    @ApiModelProperty(\&quot;$ot.comment\&quot;)\n    @TableField(value = \&quot;$tool.hump2Underline($ot.name)\&quot;)\n    private $!{tool.getClsNameByFullName($ot.type)} $!{ot.name};\n    \n#end\n}&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;entityVo.java.vm&quot;</span><span class="token punctuation">,</span>
          <span class="token property">&quot;code&quot;</span><span class="token operator">:</span> <span class="token string">&quot;##导入宏定义\n$!{define.vm}\n### 自定义全局变量 \n$!{My-mayun.vm}\n\n##保存文件（宏定义）\n#save($!{volujing}, \&quot;Vo.java\&quot;)\n\n##包路径（宏定义）\n#setPackageSuffix(\&quot;vo.$!{mokuai}\&quot;)\n\n##自动导入包（全局变量）\n$!{autoImport.vm}\n\n##表注释（宏定义）\n#tableComment(\&quot;表实体Vo类\&quot;)\n \n@Data\n@ApiModel(value = \&quot;$tableInfo.name Vo对象\&quot;, description = \&quot;\&quot;)\npublic class $!{tableInfo.name}Vo extends $!{tableInfo.name}  {\n\n}&quot;</span>
        <span class="token punctuation">}</span>
      <span class="token punctuation">]</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token property">&quot;columnConfig&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token property">&quot;全局配置&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="自定义模板语法" tabindex="-1"><a class="header-anchor" href="#自定义模板语法" aria-hidden="true">#</a> 自定义模板语法</h3><h4 id="创建变量并赋值" tabindex="-1"><a class="header-anchor" href="#创建变量并赋值" aria-hidden="true">#</a> 创建变量并赋值</h4><div class="language-vm line-numbers-mode" data-ext="vm"><pre class="language-vm"><code>#set($变量名 = $!文档属性) 调用: $!{变量名}
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h4 id="循环" tabindex="-1"><a class="header-anchor" href="#循环" aria-hidden="true">#</a> 循环</h4><ul><li><p>Velocity引擎会将list中的值循环赋给element变量</p></li><li><p>foreach.hasNext()方法用于判断是否存在下一个元素</p></li><li><p>$foreach.last表示是否是最后一个元素</p></li></ul><div class="language-vm line-numbers-mode" data-ext="vm"><pre class="language-vm"><code>#foreach($element in $list) 
    &lt;span&gt;$!element&lt;/span&gt;&lt;br&gt;
#end

foreach.hasNext() 
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="条件语句" tabindex="-1"><a class="header-anchor" href="#条件语句" aria-hidden="true">#</a> 条件语句</h4><div class="language-vm line-numbers-mode" data-ext="vm"><pre class="language-vm"><code>#if($column.comment != $null)
...
#elseif(condition)
…
#else
…
#end
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="定义全局变量" tabindex="-1"><a class="header-anchor" href="#定义全局变量" aria-hidden="true">#</a> 定义全局变量</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// 调用方法: $!{Mymodule.vm} 特别注意后缀不能掉</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p><img src="https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20230512162133542.png" alt="image-20230512162133542"></p><h3 id="mybatisplus-通用模板" tabindex="-1"><a class="header-anchor" href="#mybatisplus-通用模板" aria-hidden="true">#</a> MyBatisPlus 通用模板</h3><h4 id="controller-java-vm" tabindex="-1"><a class="header-anchor" href="#controller-java-vm" aria-hidden="true">#</a> Controller.java.vm</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>##导入宏定义
$<span class="token operator">!</span><span class="token punctuation">{</span>define<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##设置表后缀（宏定义）
#<span class="token function">setTableSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;Controller&quot;</span><span class="token punctuation">)</span>

##保存文件（宏定义）
#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;/controller&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;Controller.java&quot;</span><span class="token punctuation">)</span>

##包路径（宏定义）
#<span class="token function">setPackageSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;controller&quot;</span><span class="token punctuation">)</span>

##定义服务名 #<span class="token function">set</span><span class="token punctuation">(</span>$变量名 <span class="token operator">=</span> $<span class="token operator">!</span>文档属性<span class="token punctuation">)</span> 调用<span class="token operator">:</span> $<span class="token operator">!</span><span class="token punctuation">{</span>变量名<span class="token punctuation">}</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$serviceName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">&quot;Service&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
##定义实体对象名 <span class="token punctuation">(</span>大写<span class="token punctuation">)</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$entity <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstUpperCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">)</span>
##定义实体对象名 <span class="token punctuation">(</span>小写<span class="token punctuation">)</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$entityName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">)</span>
##定义实体<span class="token constant">VO</span>对象名
#<span class="token function">set</span><span class="token punctuation">(</span>$entityVo <span class="token operator">=</span> <span class="token string">&quot;$!{tableInfo.name}Vo&quot;</span><span class="token punctuation">)</span>
##定义实体对象名 <span class="token punctuation">(</span>小写<span class="token punctuation">)</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$entityVoName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span><span class="token string">&quot;$!{tableInfo.name}Vo&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>core<span class="token punctuation">.</span>conditions<span class="token punctuation">.</span>query<span class="token punctuation">.</span></span><span class="token class-name">QueryWrapper</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>api<span class="token punctuation">.</span></span><span class="token class-name">ApiController</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>api<span class="token punctuation">.</span></span><span class="token class-name">R</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>plugins<span class="token punctuation">.</span>pagination<span class="token punctuation">.</span></span><span class="token class-name">Page</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>savePackageName<span class="token punctuation">}</span><span class="token punctuation">.</span>entity<span class="token punctuation">.</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">;</span>
<span class="token keyword">import</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>savePackageName<span class="token punctuation">}</span><span class="token punctuation">.</span>service<span class="token punctuation">.</span>$<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Service</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>web<span class="token punctuation">.</span>bind<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token operator">*</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">javax<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Resource</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">Serializable</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span></span><span class="token punctuation">;</span>

##表注释（宏定义）
#<span class="token function">tableComment</span><span class="token punctuation">(</span><span class="token string">&quot;表控制层&quot;</span><span class="token punctuation">)</span>

<span class="token annotation punctuation">@Api</span><span class="token punctuation">(</span>tags <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;$tableInfo.comment&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@RestController</span>
<span class="token annotation punctuation">@RequestMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/$entityName&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableName<span class="token punctuation">}</span> <span class="token punctuation">{</span>
    

    <span class="token doc-comment comment">/**
     * 业务层对象
     */</span>
    <span class="token annotation punctuation">@Resource</span>
    <span class="token keyword">private</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Service</span> $<span class="token operator">!</span><span class="token punctuation">{</span>serviceName<span class="token punctuation">}</span><span class="token punctuation">;</span>
    
    
    <span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/list$!{entity}&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;获取所有数据&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> list$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token annotation punctuation">@RequestBody</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        
    <span class="token punctuation">}</span>
    
    <span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/save$!{entity}&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;新增&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> save$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token annotation punctuation">@RequestBody</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/update$!{entity}&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;修改&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> update$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token annotation punctuation">@RequestBody</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
       
    <span class="token punctuation">}</span>
    
    <span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/delete$!{entity}ById/{id}&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;根据id删除对象&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> delete$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token class-name">ById</span><span class="token punctuation">(</span><span class="token annotation punctuation">@PathVariable</span><span class="token punctuation">(</span><span class="token string">&quot;id&quot;</span><span class="token punctuation">)</span> <span class="token class-name">Integer</span> id<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;get$!{entity}ById/{id}&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;根据id查询对象数据&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> get$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token class-name">ById</span><span class="token punctuation">(</span><span class="token annotation punctuation">@PathVariable</span><span class="token punctuation">(</span><span class="token string">&quot;id&quot;</span><span class="token punctuation">)</span> <span class="token class-name">Integer</span> id<span class="token punctuation">)</span> <span class="token punctuation">{</span>
       
    <span class="token punctuation">}</span>
    
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="service-java-vm" tabindex="-1"><a class="header-anchor" href="#service-java-vm" aria-hidden="true">#</a> Service.java.vm</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>##导入宏定义
$<span class="token operator">!</span><span class="token punctuation">{</span>define<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##设置表后缀（宏定义）
#<span class="token function">setTableSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;Service&quot;</span><span class="token punctuation">)</span>

##保存文件（宏定义）
#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;/service&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;Service.java&quot;</span><span class="token punctuation">)</span>

##包路径（宏定义）
#<span class="token function">setPackageSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;service&quot;</span><span class="token punctuation">)</span>

##定义实体对象名 <span class="token punctuation">(</span>大写<span class="token punctuation">)</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$entity <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstUpperCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">)</span>
##定义实体对象名 <span class="token punctuation">(</span>小写<span class="token punctuation">)</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$entityName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">)</span>
##定义实体<span class="token constant">VO</span>对象名
#<span class="token function">set</span><span class="token punctuation">(</span>$entityVo <span class="token operator">=</span> <span class="token string">&quot;$!{tableInfo.name}Vo&quot;</span><span class="token punctuation">)</span>
##定义实体对象名 <span class="token punctuation">(</span>小写<span class="token punctuation">)</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$entityVoName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span><span class="token string">&quot;$!{tableInfo.name}Vo&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>service<span class="token punctuation">.</span></span><span class="token class-name">IService</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>plugins<span class="token punctuation">.</span>pagination<span class="token punctuation">.</span></span><span class="token class-name">Page</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>savePackageName<span class="token punctuation">}</span><span class="token punctuation">.</span>entity<span class="token punctuation">.</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">;</span>

##表注释（宏定义）
#<span class="token function">tableComment</span><span class="token punctuation">(</span><span class="token string">&quot;表服务接口&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">interface</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableName<span class="token punctuation">}</span> <span class="token keyword">extends</span> <span class="token class-name">IService</span><span class="token operator">&lt;</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token operator">&gt;</span> <span class="token punctuation">{</span>
    
<span class="token punctuation">}</span>

</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="serviceimpl-java-vm" tabindex="-1"><a class="header-anchor" href="#serviceimpl-java-vm" aria-hidden="true">#</a> ServiceImpl.java.vm</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>##导入宏定义
$<span class="token operator">!</span><span class="token punctuation">{</span>define<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##设置表后缀（宏定义）
#<span class="token function">setTableSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;ServiceImpl&quot;</span><span class="token punctuation">)</span>

##保存文件（宏定义）
#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;/service/impl&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;ServiceImpl.java&quot;</span><span class="token punctuation">)</span>

##包路径（宏定义）
#<span class="token function">setPackageSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;service.impl&quot;</span><span class="token punctuation">)</span>

##定义服务名
#<span class="token function">set</span><span class="token punctuation">(</span>$mapperName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">&quot;Mapper&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
##定义实体对象名 <span class="token punctuation">(</span>大写<span class="token punctuation">)</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$entity <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstUpperCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">)</span>
##定义实体对象名 <span class="token punctuation">(</span>小写<span class="token punctuation">)</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$entityName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">)</span>
##定义实体<span class="token constant">VO</span>对象名
#<span class="token function">set</span><span class="token punctuation">(</span>$entityVo <span class="token operator">=</span> <span class="token string">&quot;$!{tableInfo.name}Vo&quot;</span><span class="token punctuation">)</span>
##定义实体对象名 <span class="token punctuation">(</span>小写<span class="token punctuation">)</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$entityVoName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span><span class="token string">&quot;$!{tableInfo.name}Vo&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>


<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>service<span class="token punctuation">.</span>impl<span class="token punctuation">.</span></span><span class="token class-name">ServiceImpl</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>savePackageName<span class="token punctuation">}</span><span class="token punctuation">.</span>dao<span class="token punctuation">.</span>$<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Dao</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>savePackageName<span class="token punctuation">}</span><span class="token punctuation">.</span>entity<span class="token punctuation">.</span>$<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>savePackageName<span class="token punctuation">}</span><span class="token punctuation">.</span>service<span class="token punctuation">.</span>$<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Service</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>stereotype<span class="token punctuation">.</span></span><span class="token class-name">Service</span></span><span class="token punctuation">;</span>

##表注释（宏定义）
#<span class="token function">tableComment</span><span class="token punctuation">(</span><span class="token string">&quot;表服务实现类&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@Service</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableName<span class="token punctuation">}</span> <span class="token keyword">extends</span> <span class="token class-name">ServiceImpl</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Mapper</span><span class="token punctuation">,</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token operator">&gt;</span> <span class="token keyword">implements</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Service</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Mapper</span> $<span class="token operator">!</span><span class="token punctuation">{</span>mapperName<span class="token punctuation">}</span><span class="token punctuation">;</span>

<span class="token punctuation">}</span>

</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="mapper-java-vm" tabindex="-1"><a class="header-anchor" href="#mapper-java-vm" aria-hidden="true">#</a> Mapper.java.vm</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>##导入宏定义
$<span class="token operator">!</span><span class="token punctuation">{</span>define<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##设置表后缀（宏定义）
#<span class="token function">setTableSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;Mapper&quot;</span><span class="token punctuation">)</span>

##保存文件（宏定义）
#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;/mapper&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;Mapper.java&quot;</span><span class="token punctuation">)</span>

##包路径（宏定义）
#<span class="token function">setPackageSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;mapper&quot;</span><span class="token punctuation">)</span>

##定义实体对象名 <span class="token punctuation">(</span>大写<span class="token punctuation">)</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$entity <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstUpperCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">)</span>
##定义实体对象名 <span class="token punctuation">(</span>小写<span class="token punctuation">)</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$entityName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">)</span>
##定义实体<span class="token constant">VO</span>对象名
#<span class="token function">set</span><span class="token punctuation">(</span>$entityVo <span class="token operator">=</span> <span class="token string">&quot;$!{tableInfo.name}Vo&quot;</span><span class="token punctuation">)</span>
##定义实体对象名 <span class="token punctuation">(</span>小写<span class="token punctuation">)</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$entityVoName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span><span class="token string">&quot;$!{tableInfo.name}Vo&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>core<span class="token punctuation">.</span>mapper<span class="token punctuation">.</span></span><span class="token class-name">BaseMapper</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>plugins<span class="token punctuation">.</span>pagination<span class="token punctuation">.</span></span><span class="token class-name">Page</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>ibatis<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">Param</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>savePackageName<span class="token punctuation">}</span><span class="token punctuation">.</span>entity<span class="token punctuation">.</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">;</span>

##表注释（宏定义）
#<span class="token function">tableComment</span><span class="token punctuation">(</span><span class="token string">&quot;表数据库访问层&quot;</span><span class="token punctuation">)</span>

<span class="token annotation punctuation">@Mapper</span>
<span class="token keyword">public</span> <span class="token keyword">interface</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableName<span class="token punctuation">}</span> <span class="token keyword">extends</span> <span class="token class-name">BaseMapper</span><span class="token operator">&lt;</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token operator">&gt;</span> <span class="token punctuation">{</span>

    <span class="token doc-comment comment">/**
    * 批量新增数据（MyBatis原生foreach方法）
    *
    * <span class="token keyword">@param</span> <span class="token parameter">entities</span> List&lt;$!<span class="token punctuation">{</span>tableInfo.name<span class="token punctuation">}</span>&gt; 实例对象列表
    * <span class="token keyword">@return</span> 影响行数
    */</span>
    <span class="token keyword">int</span> batchSave$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token annotation punctuation">@Param</span><span class="token punctuation">(</span><span class="token string">&quot;entities&quot;</span><span class="token punctuation">)</span> <span class="token class-name">List</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token operator">&gt;</span> entities<span class="token punctuation">)</span><span class="token punctuation">;</span>


<span class="token punctuation">}</span>

</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="mapper-xml-vm" tabindex="-1"><a class="header-anchor" href="#mapper-xml-vm" aria-hidden="true">#</a> Mapper.xml.vm</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>##引入mybatis支持
$<span class="token operator">!</span><span class="token punctuation">{</span>mybatisSupport<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##设置保存名称与保存位置
$<span class="token operator">!</span>callback<span class="token punctuation">.</span><span class="token function">setFileName</span><span class="token punctuation">(</span>$tool<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span>$<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token string">&quot;Mapper.xml&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
$<span class="token operator">!</span>callback<span class="token punctuation">.</span><span class="token function">setSavePath</span><span class="token punctuation">(</span>$tool<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span>$modulePath<span class="token punctuation">,</span> <span class="token string">&quot;/src/main/resources/mapper&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>

##拿到主键
#<span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span>$tableInfo<span class="token punctuation">.</span>pkColumn<span class="token punctuation">.</span><span class="token function">isEmpty</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
    #<span class="token function">set</span><span class="token punctuation">(</span>$pk <span class="token operator">=</span> $tableInfo<span class="token punctuation">.</span>pkColumn<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
#end

##定义实体对象名 <span class="token punctuation">(</span>大写<span class="token punctuation">)</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$entity <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstUpperCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">)</span>
##定义实体对象名 <span class="token punctuation">(</span>小写<span class="token punctuation">)</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$entityName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">)</span>
##定义实体<span class="token constant">VO</span>对象名
#<span class="token function">set</span><span class="token punctuation">(</span>$entityVo <span class="token operator">=</span> <span class="token string">&quot;$!{tableInfo.name}Vo&quot;</span><span class="token punctuation">)</span>
##定义实体对象名 <span class="token punctuation">(</span>小写<span class="token punctuation">)</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$entityVoName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span><span class="token string">&quot;$!{tableInfo.name}Vo&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>


<span class="token operator">&lt;</span><span class="token operator">?</span>xml version<span class="token operator">=</span><span class="token string">&quot;1.0&quot;</span> encoding<span class="token operator">=</span><span class="token string">&quot;UTF-8&quot;</span><span class="token operator">?</span><span class="token operator">&gt;</span>
<span class="token operator">&lt;</span><span class="token operator">!</span><span class="token constant">DOCTYPE</span> mapper <span class="token constant">PUBLIC</span> <span class="token string">&quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;</span> <span class="token string">&quot;http://mybatis.org/dtd/mybatis-3-mapper.dtd&quot;</span><span class="token operator">&gt;</span>
<span class="token operator">&lt;</span>mapper namespace<span class="token operator">=</span><span class="token string">&quot;$!{tableInfo.savePackageName}.mapper.$!{tableInfo.name}Mapper&quot;</span><span class="token operator">&gt;</span>
   
    <span class="token operator">&lt;</span><span class="token operator">!</span><span class="token operator">--</span> 批量插入 <span class="token operator">--</span><span class="token operator">&gt;</span>
    <span class="token operator">&lt;</span>insert id<span class="token operator">=</span><span class="token string">&quot;batchSave$!{entity}&quot;</span> keyProperty<span class="token operator">=</span><span class="token string">&quot;$!pk.name&quot;</span> useGeneratedKeys<span class="token operator">=</span><span class="token string">&quot;true&quot;</span><span class="token operator">&gt;</span>
        insert into $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>obj<span class="token punctuation">.</span>parent<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token punctuation">.</span>$<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>obj<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token punctuation">(</span>#<span class="token function">foreach</span><span class="token punctuation">(</span>$column in $tableInfo<span class="token punctuation">.</span>otherColumn<span class="token punctuation">)</span>$<span class="token operator">!</span>column<span class="token punctuation">.</span>obj<span class="token punctuation">.</span>name#<span class="token keyword">if</span><span class="token punctuation">(</span>$velocityHasNext<span class="token punctuation">)</span><span class="token punctuation">,</span> #end#end<span class="token punctuation">)</span>
        values
        <span class="token operator">&lt;</span>foreach collection<span class="token operator">=</span><span class="token string">&quot;entities&quot;</span> item<span class="token operator">=</span><span class="token string">&quot;entity&quot;</span> separator<span class="token operator">=</span><span class="token string">&quot;,&quot;</span><span class="token operator">&gt;</span>
        <span class="token punctuation">(</span>#<span class="token function">foreach</span><span class="token punctuation">(</span>$column in $tableInfo<span class="token punctuation">.</span>otherColumn<span class="token punctuation">)</span>#<span class="token punctuation">{</span>entity<span class="token punctuation">.</span>$<span class="token operator">!</span><span class="token punctuation">{</span>column<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token punctuation">}</span>#<span class="token keyword">if</span><span class="token punctuation">(</span>$velocityHasNext<span class="token punctuation">)</span><span class="token punctuation">,</span> #end#end<span class="token punctuation">)</span>
        <span class="token operator">&lt;</span><span class="token operator">/</span>foreach<span class="token operator">&gt;</span>
    <span class="token operator">&lt;</span><span class="token operator">/</span>insert<span class="token operator">&gt;</span>
    
    <span class="token operator">&lt;</span><span class="token operator">!</span><span class="token operator">--</span> 查询 表字段 <span class="token operator">--</span><span class="token operator">&gt;</span>
    <span class="token operator">&lt;</span>sql id<span class="token operator">=</span><span class="token string">&quot;select&quot;</span><span class="token operator">&gt;</span>#<span class="token function">foreach</span><span class="token punctuation">(</span>$pk in $tableInfo<span class="token punctuation">.</span>fullColumn<span class="token punctuation">)</span>#<span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span>$foreach<span class="token punctuation">.</span>last<span class="token punctuation">)</span>

        a<span class="token punctuation">.</span>$tool<span class="token punctuation">.</span><span class="token function">hump2Underline</span><span class="token punctuation">(</span>$pk<span class="token punctuation">.</span>name<span class="token punctuation">)</span> <span class="token constant">AS</span> $<span class="token operator">!</span><span class="token punctuation">{</span>pk<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token punctuation">,</span>#<span class="token keyword">else</span>
        
        a<span class="token punctuation">.</span>$tool<span class="token punctuation">.</span><span class="token function">hump2Underline</span><span class="token punctuation">(</span>$pk<span class="token punctuation">.</span>name<span class="token punctuation">)</span> <span class="token constant">AS</span> $<span class="token operator">!</span><span class="token punctuation">{</span>pk<span class="token punctuation">.</span>name<span class="token punctuation">}</span>
   #end#end
<span class="token operator">&lt;</span><span class="token operator">/</span>sql<span class="token operator">&gt;</span>

    <span class="token operator">&lt;</span><span class="token operator">!</span><span class="token operator">--</span> 表字段 动态条件 <span class="token operator">--</span><span class="token operator">&gt;</span>
    <span class="token operator">&lt;</span>sql id<span class="token operator">=</span><span class="token string">&quot;where&quot;</span><span class="token operator">&gt;</span>
#<span class="token function">foreach</span><span class="token punctuation">(</span>$column in $tableInfo<span class="token punctuation">.</span>fullColumn<span class="token punctuation">)</span> 
        <span class="token operator">&lt;</span><span class="token keyword">if</span> test<span class="token operator">=</span><span class="token string">&quot;entity.$!{column.name}#if($velocityHasNext)#end != null and entity.$!{column.name}#if($velocityHasNext)#end != &#39;&#39;&quot;</span><span class="token operator">&gt;</span>
            and a<span class="token punctuation">.</span>$<span class="token operator">!</span>column<span class="token punctuation">.</span>obj<span class="token punctuation">.</span>name#<span class="token keyword">if</span><span class="token punctuation">(</span>$velocityHasNext<span class="token punctuation">)</span>#end <span class="token operator">=</span> #<span class="token punctuation">{</span>entity<span class="token punctuation">.</span>$<span class="token operator">!</span><span class="token punctuation">{</span>column<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token punctuation">}</span>#<span class="token keyword">if</span><span class="token punctuation">(</span>$velocityHasNext<span class="token punctuation">)</span>#end           
        
        <span class="token operator">&lt;</span><span class="token operator">/</span><span class="token keyword">if</span><span class="token operator">&gt;</span>
#end
    <span class="token operator">&lt;</span><span class="token operator">/</span>sql<span class="token operator">&gt;</span>

<span class="token operator">&lt;</span><span class="token operator">/</span>mapper<span class="token operator">&gt;</span>

</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="entity-java-vm" tabindex="-1"><a class="header-anchor" href="#entity-java-vm" aria-hidden="true">#</a> entity.java.vm</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>##导入宏定义
$<span class="token operator">!</span><span class="token punctuation">{</span>define<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##保存文件（宏定义）#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;生成有组织路径则加在这 /文件位置&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;entity + 自定义后缀.java&quot;</span><span class="token punctuation">)</span>
### 例如<span class="token operator">:</span><span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;\com\my\pin\entity\sanitary&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;.java&quot;</span><span class="token punctuation">)</span>
#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;/entity&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;.java&quot;</span><span class="token punctuation">)</span>

##包路径（宏定义）例如<span class="token operator">:</span> #<span class="token function">setPackageSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;生成有组织路径则加在这. entity.sanitary&quot;</span><span class="token punctuation">)</span>
#<span class="token function">setPackageSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;entity&quot;</span><span class="token punctuation">)</span>

##自动导入包（全局变量）
$<span class="token operator">!</span><span class="token punctuation">{</span>autoImport<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>activerecord<span class="token punctuation">.</span></span><span class="token class-name">Model</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">Serializable</span></span><span class="token punctuation">;</span>

##表注释（宏定义）
#<span class="token function">tableComment</span><span class="token punctuation">(</span><span class="token string">&quot;表实体类&quot;</span><span class="token punctuation">)</span>
 
<span class="token annotation punctuation">@Data</span>
<span class="token annotation punctuation">@TableName</span><span class="token punctuation">(</span><span class="token string">&quot;$!{tool.firstLowerCase($!{tool.hump2Underline($!{tableInfo.name})})}&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@ApiModel</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;$tableInfo.name 对象&quot;</span><span class="token punctuation">,</span> description <span class="token operator">=</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span> <span class="token keyword">implements</span> <span class="token class-name">Serializable</span>  <span class="token punctuation">{</span>

    <span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token keyword">long</span> serialVersionUID <span class="token operator">=</span> <span class="token number">1L</span><span class="token punctuation">;</span>

#<span class="token function">foreach</span><span class="token punctuation">(</span>$pk in $tableInfo<span class="token punctuation">.</span>pkColumn<span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span><span class="token string">&quot;$pk.comment&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@TableId</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;$tool.hump2Underline(&quot;</span>$pk<span class="token punctuation">.</span>name<span class="token string">&quot;)&quot;</span><span class="token punctuation">,</span> type <span class="token operator">=</span> <span class="token class-name">IdType</span><span class="token punctuation">.</span><span class="token constant">AUTO</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tool<span class="token punctuation">.</span><span class="token function">getClsNameByFullName</span><span class="token punctuation">(</span>$pk<span class="token punctuation">.</span>type<span class="token punctuation">)</span><span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>pk<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token punctuation">;</span>
#end

#<span class="token function">foreach</span><span class="token punctuation">(</span>$ot in $tableInfo<span class="token punctuation">.</span>otherColumn<span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span><span class="token string">&quot;$ot.comment&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;$tool.hump2Underline($ot.name)&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tool<span class="token punctuation">.</span><span class="token function">getClsNameByFullName</span><span class="token punctuation">(</span>$ot<span class="token punctuation">.</span>type<span class="token punctuation">)</span><span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>ot<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token punctuation">;</span>
#end
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="entityvo-java-vm" tabindex="-1"><a class="header-anchor" href="#entityvo-java-vm" aria-hidden="true">#</a> entityVo.java.vm</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>##导入宏定义
$<span class="token operator">!</span><span class="token punctuation">{</span>define<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##保存文件（宏定义）
#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;/vo&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;Vo.java&quot;</span><span class="token punctuation">)</span>

##包路径（宏定义）
#<span class="token function">setPackageSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;vo&quot;</span><span class="token punctuation">)</span>

##自动导入包（全局变量）
$<span class="token operator">!</span><span class="token punctuation">{</span>autoImport<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##表注释（宏定义）
#<span class="token function">tableComment</span><span class="token punctuation">(</span><span class="token string">&quot;表实体Vo类&quot;</span><span class="token punctuation">)</span>
 
<span class="token annotation punctuation">@Data</span>
<span class="token annotation punctuation">@ApiModel</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;$tableInfo.name Vo对象&quot;</span><span class="token punctuation">,</span> description <span class="token operator">=</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Vo</span> <span class="token keyword">extends</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span>  <span class="token punctuation">{</span>

<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="自定义位置-生成模板" tabindex="-1"><a class="header-anchor" href="#自定义位置-生成模板" aria-hidden="true">#</a> 自定义位置 生成模板</h3><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// com.my.pin</span>

<span class="token comment">// 实体类:</span>
<span class="token class-name">C</span><span class="token operator">:</span>\<span class="token class-name">Users</span>\码云\<span class="token class-name">Documents</span>\<span class="token class-name">Mayun</span>\<span class="token class-name">Mayun_Sanitary_Apai</span>
\common\common_entity\src\main\java\com\my\pin\entity\sanitary

<span class="token comment">// VO类: </span>
<span class="token class-name">C</span><span class="token operator">:</span>\<span class="token class-name">Users</span>\码云\<span class="token class-name">Documents</span>\<span class="token class-name">Mayun</span>\<span class="token class-name">Mayun_Sanitary_Apai</span>
\common\common_entity\src\main\java\com\my\pin\vo\sanitary
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="全局变量" tabindex="-1"><a class="header-anchor" href="#全局变量" aria-hidden="true">#</a> 全局变量</h4><blockquote><p>My-mayun.vm</p></blockquote><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code>#<span class="token function">#定义实体对象名</span> <span class="token punctuation">(</span>大写<span class="token punctuation">)</span>
<span class="token function">#set</span><span class="token punctuation">(</span>$entity <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstUpperCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">)</span>
#<span class="token function">#定义实体对象名</span> <span class="token punctuation">(</span>小写<span class="token punctuation">)</span>
<span class="token function">#set</span><span class="token punctuation">(</span>$entityName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">)</span>
##定义实体<span class="token constant">VO</span>对象名
<span class="token function">#set</span><span class="token punctuation">(</span>$entityVo <span class="token operator">=</span> <span class="token string">&quot;$!{tableInfo.name}Vo&quot;</span><span class="token punctuation">)</span>
#<span class="token function">#定义实体对象名</span> <span class="token punctuation">(</span>小写<span class="token punctuation">)</span>
<span class="token function">#set</span><span class="token punctuation">(</span>$entityVoName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span><span class="token string">&quot;$!{tableInfo.name}Vo&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>

### 模块名称 用于实体类 vo生成路径 已经其他导入的包路径 
<span class="token function">#set</span><span class="token punctuation">(</span>$mokuai <span class="token operator">=</span> <span class="token string">&quot;sanitary&quot;</span><span class="token punctuation">)</span>
<span class="token function">#set</span><span class="token punctuation">(</span>$entitylujing <span class="token operator">=</span> <span class="token string">&quot;\entity\sanitary&quot;</span><span class="token punctuation">)</span>
<span class="token function">#set</span><span class="token punctuation">(</span>$volujing <span class="token operator">=</span> <span class="token string">&quot;\vo\sanitary&quot;</span><span class="token punctuation">)</span>
### 导包 实体类 vo
<span class="token function">#set</span><span class="token punctuation">(</span>$ie <span class="token operator">=</span> <span class="token string">&quot;import $!{tableInfo.savePackageName}.entity.$!{mokuai}.$!{entity};&quot;</span><span class="token punctuation">)</span>
<span class="token function">#set</span><span class="token punctuation">(</span>$iev <span class="token operator">=</span> <span class="token string">&quot;import $!{tableInfo.savePackageName}.vo.$!{mokuai}.$!{entity}Vo;&quot;</span><span class="token punctuation">)</span>
### 实体类 vo 路径 用于mapper<span class="token punctuation">.</span>xml内
<span class="token function">#set</span><span class="token punctuation">(</span>$me <span class="token operator">=</span> <span class="token string">&quot;$!{tableInfo.savePackageName}.entity.$!{mokuai}.$!{entity}&quot;</span><span class="token punctuation">)</span>
<span class="token function">#set</span><span class="token punctuation">(</span>$mev <span class="token operator">=</span> <span class="token string">&quot;$!{tableInfo.savePackageName}.vo.$!{mokuai}.$!{entity}Vo&quot;</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="自定义位置" tabindex="-1"><a class="header-anchor" href="#自定义位置" aria-hidden="true">#</a> 自定义位置</h4><ul><li>更改 全局变量: 模块名称-实体类导包路径</li><li>更改 实体类: #save(&quot;\entity\自定义路径&quot;, &quot;.java&quot;) | (读取不到 全局变量的模块值 很烦只能写死sanitary)</li><li>在创建时 选择正确的项目 组织名称 生成位置</li></ul><h4 id="controller-java-vm-1" tabindex="-1"><a class="header-anchor" href="#controller-java-vm-1" aria-hidden="true">#</a> Controller.java.vm</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>##导入宏定义
$<span class="token operator">!</span><span class="token punctuation">{</span>define<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##设置表后缀（宏定义）
#<span class="token function">setTableSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;Controller&quot;</span><span class="token punctuation">)</span>

##保存文件（宏定义）
#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;/controller&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;Controller.java&quot;</span><span class="token punctuation">)</span>

##包路径（宏定义）
#<span class="token function">setPackageSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;controller&quot;</span><span class="token punctuation">)</span>

##定义服务名 #<span class="token function">set</span><span class="token punctuation">(</span>$变量名 <span class="token operator">=</span> $<span class="token operator">!</span>文档属性<span class="token punctuation">)</span> 调用<span class="token operator">:</span> $<span class="token operator">!</span><span class="token punctuation">{</span>变量名<span class="token punctuation">}</span>
#<span class="token function">set</span><span class="token punctuation">(</span>$serviceName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">&quot;Service&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
### 自定义全局变量 
$<span class="token operator">!</span><span class="token punctuation">{</span><span class="token class-name">My</span><span class="token operator">-</span>mayun<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>
### 实体类 和 vo类的导包
$<span class="token operator">!</span><span class="token punctuation">{</span>ie<span class="token punctuation">}</span>
$<span class="token operator">!</span><span class="token punctuation">{</span>iev<span class="token punctuation">}</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>core<span class="token punctuation">.</span>conditions<span class="token punctuation">.</span>query<span class="token punctuation">.</span></span><span class="token class-name">QueryWrapper</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>api<span class="token punctuation">.</span></span><span class="token class-name">ApiController</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>plugins<span class="token punctuation">.</span>pagination<span class="token punctuation">.</span></span><span class="token class-name">Page</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>savePackageName<span class="token punctuation">}</span><span class="token punctuation">.</span>service<span class="token punctuation">.</span>$<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Service</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>web<span class="token punctuation">.</span>bind<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token operator">*</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">javax<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Resource</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">Serializable</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span></span><span class="token punctuation">;</span>

##表注释（宏定义）
#<span class="token function">tableComment</span><span class="token punctuation">(</span><span class="token string">&quot;表控制层&quot;</span><span class="token punctuation">)</span>

<span class="token annotation punctuation">@Api</span><span class="token punctuation">(</span>tags <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;$tableInfo.comment&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@RestController</span>
<span class="token annotation punctuation">@RequestMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/$entityName&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableName<span class="token punctuation">}</span> <span class="token punctuation">{</span>
    

    <span class="token doc-comment comment">/**
     * 业务层对象
     */</span>
    <span class="token annotation punctuation">@Resource</span>
    <span class="token keyword">private</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Service</span> $<span class="token operator">!</span><span class="token punctuation">{</span>serviceName<span class="token punctuation">}</span><span class="token punctuation">;</span>
    
    
    <span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/list$!{entity}&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;获取所有数据&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token class-name">TableR</span> list$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token annotation punctuation">@RequestBody</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">// 分页对象 数据集合 总条数 合计</span>
        <span class="token class-name">Page</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span><span class="token operator">&gt;</span> page <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Page</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">.</span><span class="token function">getPage</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">.</span><span class="token function">getLimit</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">List</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span><span class="token operator">&gt;</span> list <span class="token operator">=</span> $<span class="token operator">!</span><span class="token punctuation">{</span>serviceName<span class="token punctuation">}</span><span class="token punctuation">.</span>list$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span>page<span class="token punctuation">,</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Long</span> number <span class="token operator">=</span> page<span class="token punctuation">.</span><span class="token function">getTotal</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// $!{entityVo} total = $!{serviceName}.total$!{entity}($!{entityVoName});</span>
        <span class="token keyword">return</span> <span class="token class-name">TableR</span><span class="token punctuation">.</span><span class="token function">success</span><span class="token punctuation">(</span>list<span class="token punctuation">,</span> number<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/save$!{entity}&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;新增&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token class-name">R</span> save$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token annotation punctuation">@RequestBody</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> $<span class="token operator">!</span><span class="token punctuation">{</span>serviceName<span class="token punctuation">}</span><span class="token punctuation">.</span>save$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/update$!{entity}&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;修改&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token class-name">R</span> update$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token annotation punctuation">@RequestBody</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> $<span class="token operator">!</span><span class="token punctuation">{</span>serviceName<span class="token punctuation">}</span><span class="token punctuation">.</span>update$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/delete$!{entity}ById/{id}&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;根据id删除对象&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token class-name">R</span> delete$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token class-name">ById</span><span class="token punctuation">(</span><span class="token annotation punctuation">@PathVariable</span><span class="token punctuation">(</span><span class="token string">&quot;id&quot;</span><span class="token punctuation">)</span> <span class="token class-name">Integer</span> id<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> $<span class="token operator">!</span><span class="token punctuation">{</span>serviceName<span class="token punctuation">}</span><span class="token punctuation">.</span>delete$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token class-name">ById</span><span class="token punctuation">(</span>id<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;get$!{entity}ById/{id}&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;根据id查询对象数据&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token class-name">R</span> get$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token class-name">ById</span><span class="token punctuation">(</span><span class="token annotation punctuation">@PathVariable</span><span class="token punctuation">(</span><span class="token string">&quot;id&quot;</span><span class="token punctuation">)</span> <span class="token class-name">Integer</span> id<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token class-name">R</span><span class="token punctuation">.</span><span class="token function">success</span><span class="token punctuation">(</span>$<span class="token operator">!</span><span class="token punctuation">{</span>serviceName<span class="token punctuation">}</span><span class="token punctuation">.</span>get$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token class-name">ById</span><span class="token punctuation">(</span>id<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;list$!{entity}Choice&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;下拉框&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token class-name">R</span> list$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token class-name">Choice</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token class-name">R</span><span class="token punctuation">.</span><span class="token function">success</span><span class="token punctuation">(</span>$<span class="token operator">!</span><span class="token punctuation">{</span>serviceName<span class="token punctuation">}</span><span class="token punctuation">.</span>list$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token class-name">Choice</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;exportExcel$!{entity}&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;导出Excel&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> exportExcel$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token annotation punctuation">@RequestBody</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token class-name">Page</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span><span class="token operator">&gt;</span> page <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Page</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token class-name">Integer</span><span class="token punctuation">.</span><span class="token constant">MAX_VALUE</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">List</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span><span class="token operator">&gt;</span> list <span class="token operator">=</span> $<span class="token operator">!</span><span class="token punctuation">{</span>serviceName<span class="token punctuation">}</span><span class="token punctuation">.</span>list$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span>page<span class="token punctuation">,</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> fileName <span class="token operator">=</span> <span class="token string">&quot;$!{tableInfo.comment}&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">EasyPoiExcelUtils</span><span class="token punctuation">.</span><span class="token function">exportExcel</span><span class="token punctuation">(</span>list<span class="token punctuation">,</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> <span class="token string">&quot;$!{tableInfo.comment}&quot;</span> <span class="token operator">+</span> <span class="token class-name">DateUtils</span><span class="token punctuation">.</span><span class="token function">farmtDateMin</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">&quot;.xlsx&quot;</span><span class="token punctuation">,</span> response<span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">ExportParams</span><span class="token punctuation">(</span>fileName<span class="token punctuation">,</span> <span class="token string">&quot;sheet1&quot;</span><span class="token punctuation">,</span> <span class="token class-name">ExcelType</span><span class="token punctuation">.</span><span class="token constant">XSSF</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;importExcel$!{entity}&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;导入Excel&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token class-name">R</span> importExcel$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token class-name">MultipartFile</span> file<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token class-name">Objects</span><span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span>file<span class="token punctuation">,</span><span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
            <span class="token keyword">return</span> <span class="token class-name">R</span><span class="token punctuation">.</span><span class="token function">error</span><span class="token punctuation">(</span><span class="token string">&quot;请添加附件&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token keyword">else</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> $<span class="token operator">!</span><span class="token punctuation">{</span>serviceName<span class="token punctuation">}</span><span class="token punctuation">.</span>importExcel$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span>file<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="service-java-vm-1" tabindex="-1"><a class="header-anchor" href="#service-java-vm-1" aria-hidden="true">#</a> Service.java.vm</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>##导入宏定义
$<span class="token operator">!</span><span class="token punctuation">{</span>define<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##设置表后缀（宏定义）
#<span class="token function">setTableSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;Service&quot;</span><span class="token punctuation">)</span>

##保存文件（宏定义）
#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;/service&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;Service.java&quot;</span><span class="token punctuation">)</span>

##包路径（宏定义）
#<span class="token function">setPackageSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;service&quot;</span><span class="token punctuation">)</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>my<span class="token punctuation">.</span>pin<span class="token punctuation">.</span>result<span class="token punctuation">.</span></span><span class="token class-name">R</span></span><span class="token punctuation">;</span>
### 自定义全局变量 
$<span class="token operator">!</span><span class="token punctuation">{</span><span class="token class-name">My</span><span class="token operator">-</span>mayun<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>
### 实体类 和 vo类的导包
$<span class="token operator">!</span><span class="token punctuation">{</span>ie<span class="token punctuation">}</span>
$<span class="token operator">!</span><span class="token punctuation">{</span>iev<span class="token punctuation">}</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>service<span class="token punctuation">.</span></span><span class="token class-name">IService</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>plugins<span class="token punctuation">.</span>pagination<span class="token punctuation">.</span></span><span class="token class-name">Page</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span></span><span class="token punctuation">;</span>

##表注释（宏定义）
#<span class="token function">tableComment</span><span class="token punctuation">(</span><span class="token string">&quot;表服务接口&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">interface</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableName<span class="token punctuation">}</span> <span class="token keyword">extends</span> <span class="token class-name">IService</span><span class="token operator">&lt;</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token operator">&gt;</span> <span class="token punctuation">{</span>

 <span class="token doc-comment comment">/**
     * 获取主表所有数据
     * <span class="token keyword">@param</span> <span class="token parameter">page</span>
     * <span class="token keyword">@param</span> $!<span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span>
     * <span class="token keyword">@return</span>
     */</span>
    <span class="token class-name">List</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span><span class="token operator">&gt;</span> list$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token class-name">Page</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span><span class="token operator">&gt;</span> page<span class="token punctuation">,</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * 保存
     * <span class="token keyword">@param</span> $!<span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span>
     * <span class="token keyword">@return</span>
     */</span>
    <span class="token class-name">R</span> save$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * 修改
     * <span class="token keyword">@param</span> $!<span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span>
     * <span class="token keyword">@return</span>
     */</span>
    <span class="token class-name">R</span> update$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * 删除
     * <span class="token keyword">@param</span> <span class="token parameter">id</span>
     * <span class="token keyword">@return</span>
     */</span>
    <span class="token class-name">R</span> delete$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token class-name">ById</span><span class="token punctuation">(</span><span class="token class-name">Integer</span> id<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * 根据id获取数据
     * <span class="token keyword">@param</span> <span class="token parameter">id</span>
     * <span class="token keyword">@return</span>
     */</span>
    $<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> get$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token class-name">ById</span><span class="token punctuation">(</span><span class="token class-name">Integer</span> id<span class="token punctuation">)</span><span class="token punctuation">;</span>
    
    <span class="token doc-comment comment">/**
     * 获取下拉
     * <span class="token keyword">@return</span>
     */</span>
    <span class="token class-name">List</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token operator">&gt;</span> list$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token class-name">Choice</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    
     <span class="token doc-comment comment">/**
     * 读取Excel数据导入数据库
     * <span class="token keyword">@param</span> <span class="token parameter">file</span>
     * <span class="token keyword">@return</span>
     * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">Exception</span></span>
     */</span>
    <span class="token class-name">R</span> importExcel$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token class-name">MultipartFile</span> file<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span><span class="token punctuation">;</span>
    
<span class="token punctuation">}</span>

</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="serviceimpl-java-vm-1" tabindex="-1"><a class="header-anchor" href="#serviceimpl-java-vm-1" aria-hidden="true">#</a> ServiceImpl.java.vm</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>##导入宏定义
$<span class="token operator">!</span><span class="token punctuation">{</span>define<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##设置表后缀（宏定义）
#<span class="token function">setTableSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;ServiceImpl&quot;</span><span class="token punctuation">)</span>

##保存文件（宏定义）
#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;/service/impl&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;ServiceImpl.java&quot;</span><span class="token punctuation">)</span>

##包路径（宏定义）
#<span class="token function">setPackageSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;service.impl&quot;</span><span class="token punctuation">)</span>

##定义服务名
#<span class="token function">set</span><span class="token punctuation">(</span>$mapperName <span class="token operator">=</span> $<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tool<span class="token punctuation">.</span><span class="token function">firstLowerCase</span><span class="token punctuation">(</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">&quot;Mapper&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
### 自定义全局变量 
$<span class="token operator">!</span><span class="token punctuation">{</span><span class="token class-name">My</span><span class="token operator">-</span>mayun<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>
### 实体类 和 vo类的导包
$<span class="token operator">!</span><span class="token punctuation">{</span>ie<span class="token punctuation">}</span>
$<span class="token operator">!</span><span class="token punctuation">{</span>iev<span class="token punctuation">}</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>service<span class="token punctuation">.</span>impl<span class="token punctuation">.</span></span><span class="token class-name">ServiceImpl</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>savePackageName<span class="token punctuation">}</span><span class="token punctuation">.</span>mapper<span class="token punctuation">.</span>$<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Mapper</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>savePackageName<span class="token punctuation">}</span><span class="token punctuation">.</span>service<span class="token punctuation">.</span>$<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Service</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>stereotype<span class="token punctuation">.</span></span><span class="token class-name">Service</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>beans<span class="token punctuation">.</span></span><span class="token class-name">BeanUtils</span></span><span class="token punctuation">;</span>

##表注释（宏定义）
#<span class="token function">tableComment</span><span class="token punctuation">(</span><span class="token string">&quot;表服务实现类&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@Service</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableName<span class="token punctuation">}</span> <span class="token keyword">extends</span> <span class="token class-name">ServiceImpl</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Mapper</span><span class="token punctuation">,</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token operator">&gt;</span> <span class="token keyword">implements</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Service</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Mapper</span> $<span class="token operator">!</span><span class="token punctuation">{</span>mapperName<span class="token punctuation">}</span><span class="token punctuation">;</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">List</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span><span class="token operator">&gt;</span> list$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token class-name">Page</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span><span class="token operator">&gt;</span> page<span class="token punctuation">,</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> baseMapper<span class="token punctuation">.</span>list$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span>page<span class="token punctuation">,</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">R</span> save$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">int</span> insert <span class="token operator">=</span> baseMapper<span class="token punctuation">.</span><span class="token function">insert</span><span class="token punctuation">(</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> <span class="token class-name">R</span><span class="token punctuation">.</span><span class="token function">success</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">R</span> update$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">// 修改数据</span>
        <span class="token keyword">int</span> update <span class="token operator">=</span> baseMapper<span class="token punctuation">.</span><span class="token function">updateById</span><span class="token punctuation">(</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> <span class="token class-name">R</span><span class="token punctuation">.</span><span class="token function">success</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">R</span> delete$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token class-name">ById</span><span class="token punctuation">(</span><span class="token class-name">Integer</span> id<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">int</span> i <span class="token operator">=</span> baseMapper<span class="token punctuation">.</span><span class="token function">deleteById</span><span class="token punctuation">(</span>id<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> <span class="token class-name">R</span><span class="token punctuation">.</span><span class="token function">success</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> get$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token class-name">ById</span><span class="token punctuation">(</span><span class="token class-name">Integer</span> id<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        $<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityName<span class="token punctuation">}</span> <span class="token operator">=</span> baseMapper<span class="token punctuation">.</span><span class="token function">selectById</span><span class="token punctuation">(</span>id<span class="token punctuation">)</span><span class="token punctuation">;</span>
        $<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span> <span class="token operator">=</span> <span class="token keyword">new</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">BeanUtils</span><span class="token punctuation">.</span><span class="token function">copyProperties</span><span class="token punctuation">(</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityName<span class="token punctuation">}</span><span class="token punctuation">,</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">List</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token operator">&gt;</span> list$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token class-name">Choice</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">QueryWrapper</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token operator">&gt;</span> where <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">QueryWrapper</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 查询条件省略...</span>
        <span class="token keyword">return</span> baseMapper<span class="token punctuation">.</span><span class="token function">selectList</span><span class="token punctuation">(</span>where<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
     <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">R</span> importExcel$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token class-name">MultipartFile</span> file<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
        <span class="token comment">// 步骤按照其他参考...</span>
        <span class="token keyword">return</span> <span class="token class-name">R</span><span class="token punctuation">.</span><span class="token function">success</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
<span class="token punctuation">}</span>

</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="mapper-java-vm-1" tabindex="-1"><a class="header-anchor" href="#mapper-java-vm-1" aria-hidden="true">#</a> Mapper.java.vm</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>##导入宏定义
$<span class="token operator">!</span><span class="token punctuation">{</span>define<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##设置表后缀（宏定义）
#<span class="token function">setTableSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;Mapper&quot;</span><span class="token punctuation">)</span>

##保存文件（宏定义）
#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;/mapper&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;Mapper.java&quot;</span><span class="token punctuation">)</span>

##包路径（宏定义）
#<span class="token function">setPackageSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;mapper&quot;</span><span class="token punctuation">)</span>

### 自定义全局变量 
$<span class="token operator">!</span><span class="token punctuation">{</span><span class="token class-name">My</span><span class="token operator">-</span>mayun<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>
### 实体类 和 vo类的导包
$<span class="token operator">!</span><span class="token punctuation">{</span>ie<span class="token punctuation">}</span>
$<span class="token operator">!</span><span class="token punctuation">{</span>iev<span class="token punctuation">}</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>core<span class="token punctuation">.</span>mapper<span class="token punctuation">.</span></span><span class="token class-name">BaseMapper</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>plugins<span class="token punctuation">.</span>pagination<span class="token punctuation">.</span></span><span class="token class-name">Page</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>ibatis<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">Param</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span></span><span class="token punctuation">;</span>

### 实体类 vo类 导包路径
$<span class="token operator">!</span><span class="token punctuation">{</span><span class="token class-name">Myentity</span><span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##表注释（宏定义）
#<span class="token function">tableComment</span><span class="token punctuation">(</span><span class="token string">&quot;表数据库访问层&quot;</span><span class="token punctuation">)</span>

<span class="token annotation punctuation">@Mapper</span>
<span class="token keyword">public</span> <span class="token keyword">interface</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableName<span class="token punctuation">}</span> <span class="token keyword">extends</span> <span class="token class-name">BaseMapper</span><span class="token operator">&lt;</span>$<span class="token operator">!</span>tableInfo<span class="token punctuation">.</span>name<span class="token operator">&gt;</span> <span class="token punctuation">{</span>

    <span class="token doc-comment comment">/**
     * 获取主表所有数据
     * <span class="token keyword">@param</span> <span class="token parameter">page</span>
     * <span class="token keyword">@param</span> $!<span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span>
     * <span class="token keyword">@return</span>
     */</span>
    <span class="token class-name">List</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span><span class="token operator">&gt;</span> list$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token class-name">Page</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span><span class="token operator">&gt;</span> page<span class="token punctuation">,</span> <span class="token annotation punctuation">@Param</span><span class="token punctuation">(</span><span class="token string">&quot;entity&quot;</span><span class="token punctuation">)</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVo<span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>entityVoName<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
    * 批量新增数据（MyBatis原生foreach方法）
    *
    * <span class="token keyword">@param</span> <span class="token parameter">entities</span> List&lt;$!<span class="token punctuation">{</span>tableInfo.name<span class="token punctuation">}</span>&gt; 实例对象列表
    * <span class="token keyword">@return</span> 影响行数
    */</span>
    <span class="token keyword">int</span> batchSave$<span class="token operator">!</span><span class="token punctuation">{</span>entity<span class="token punctuation">}</span><span class="token punctuation">(</span><span class="token annotation punctuation">@Param</span><span class="token punctuation">(</span><span class="token string">&quot;entities&quot;</span><span class="token punctuation">)</span> <span class="token class-name">List</span><span class="token operator">&lt;</span>$<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token operator">&gt;</span> entities<span class="token punctuation">)</span><span class="token punctuation">;</span>


<span class="token punctuation">}</span>

</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="mapper-xml-vm-1" tabindex="-1"><a class="header-anchor" href="#mapper-xml-vm-1" aria-hidden="true">#</a> Mapper.xml.vm</h4><div class="language-xml line-numbers-mode" data-ext="xml"><pre class="language-xml"><code>##引入mybatis支持
$!{mybatisSupport.vm}

##设置保存名称与保存位置
$!callback.setFileName($tool.append($!{tableInfo.name}, &quot;Mapper.xml&quot;))
$!callback.setSavePath($tool.append($modulePath, &quot;/src/main/resources/mapper&quot;))

##拿到主键
#if(!$tableInfo.pkColumn.isEmpty())
    #set($pk = $tableInfo.pkColumn.get(0))
#end

### 自定义全局变量 
$!{My-mayun.vm}


<span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token doctype"><span class="token punctuation">&lt;!</span><span class="token doctype-tag">DOCTYPE</span> <span class="token name">mapper</span> <span class="token name">PUBLIC</span> <span class="token string">&quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;</span> <span class="token string">&quot;http://mybatis.org/dtd/mybatis-3-mapper.dtd&quot;</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>mapper</span> <span class="token attr-name">namespace</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>$!{tableInfo.savePackageName}.mapper.$!{tableInfo.name}Mapper<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>

    <span class="token comment">&lt;!-- 查询列表 --&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>select</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>list$!{entity}<span class="token punctuation">&quot;</span></span> <span class="token attr-name">resultType</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>$!{mev}<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        SELECT
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>include</span> <span class="token attr-name">refid</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>select<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        FROM
            $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name} a
        WHERE a.status = 1
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>include</span> <span class="token attr-name">refid</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>where<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        order by a.create_time desc
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>select</span><span class="token punctuation">&gt;</span></span>
   
    <span class="token comment">&lt;!-- 批量插入 --&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>insert</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>batchSave$!{entity}<span class="token punctuation">&quot;</span></span> <span class="token attr-name">keyProperty</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>$!pk.name<span class="token punctuation">&quot;</span></span> <span class="token attr-name">useGeneratedKeys</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)
        values
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>foreach</span> <span class="token attr-name">collection</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>entities<span class="token punctuation">&quot;</span></span> <span class="token attr-name">item</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>entity<span class="token punctuation">&quot;</span></span> <span class="token attr-name">separator</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>,<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end)
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>foreach</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>insert</span><span class="token punctuation">&gt;</span></span>

    <span class="token comment">&lt;!-- 查询 表字段 --&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>sql</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>select<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>#foreach($pk in $tableInfo.fullColumn)#if(!$foreach.last)

        a.$tool.hump2Underline($pk.name) AS $!{pk.name},#else
        
        a.$tool.hump2Underline($pk.name) AS $!{pk.name}
   #end#end
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>sql</span><span class="token punctuation">&gt;</span></span>

    <span class="token comment">&lt;!-- 表字段 动态条件 --&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>sql</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>where<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
#foreach($column in $tableInfo.fullColumn) 
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>if</span> <span class="token attr-name">test</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>entity.$!{column.name}#if($velocityHasNext)#end != null and entity.$!{column.name}#if($velocityHasNext)#end != &#39;&#39;<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
            and a.$!column.obj.name#if($velocityHasNext)#end = #{entity.$!{column.name}}#if($velocityHasNext)#end           
        
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>if</span><span class="token punctuation">&gt;</span></span>
#end
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>sql</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>mapper</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="entity-java-vm-1" tabindex="-1"><a class="header-anchor" href="#entity-java-vm-1" aria-hidden="true">#</a> entity.java.vm</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>##导入宏定义
$<span class="token operator">!</span><span class="token punctuation">{</span>define<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>
### 自定义全局变量 
$<span class="token operator">!</span><span class="token punctuation">{</span><span class="token class-name">My</span><span class="token operator">-</span>mayun<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##保存文件（宏定义）#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;生成有组织路径则加在这/文件位置&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;entity + 自定义后缀.java&quot;</span><span class="token punctuation">)</span>
#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;$!{entitylujing}&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;.java&quot;</span><span class="token punctuation">)</span>

##包路径（宏定义）
#<span class="token function">setPackageSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;entity.$!{mokuai}&quot;</span><span class="token punctuation">)</span>

##自动导入包（全局变量）
$<span class="token operator">!</span><span class="token punctuation">{</span>autoImport<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>activerecord<span class="token punctuation">.</span></span><span class="token class-name">Model</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">Serializable</span></span><span class="token punctuation">;</span>

##表注释（宏定义）
#<span class="token function">tableComment</span><span class="token punctuation">(</span><span class="token string">&quot;表实体类&quot;</span><span class="token punctuation">)</span>
 
<span class="token annotation punctuation">@Data</span>
<span class="token annotation punctuation">@TableName</span><span class="token punctuation">(</span><span class="token string">&quot;$!{tool.firstLowerCase($!{tool.hump2Underline($!{tableInfo.name})})}&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@ApiModel</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;$tableInfo.name 对象&quot;</span><span class="token punctuation">,</span> description <span class="token operator">=</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span> <span class="token keyword">extends</span> <span class="token class-name">BaseEntity</span> <span class="token keyword">implements</span> <span class="token class-name">Serializable</span>  <span class="token punctuation">{</span>

#<span class="token function">foreach</span><span class="token punctuation">(</span>$pk in $tableInfo<span class="token punctuation">.</span>pkColumn<span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span><span class="token string">&quot;$pk.comment&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@TableId</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;$tool.hump2Underline(&quot;</span>$pk<span class="token punctuation">.</span>name<span class="token string">&quot;)&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tool<span class="token punctuation">.</span><span class="token function">getClsNameByFullName</span><span class="token punctuation">(</span>$pk<span class="token punctuation">.</span>type<span class="token punctuation">)</span><span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>pk<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token punctuation">;</span>
#end

#<span class="token function">foreach</span><span class="token punctuation">(</span>$ot in $tableInfo<span class="token punctuation">.</span>otherColumn<span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span><span class="token string">&quot;$ot.comment&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;$tool.hump2Underline($ot.name)&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tool<span class="token punctuation">.</span><span class="token function">getClsNameByFullName</span><span class="token punctuation">(</span>$ot<span class="token punctuation">.</span>type<span class="token punctuation">)</span><span class="token punctuation">}</span> $<span class="token operator">!</span><span class="token punctuation">{</span>ot<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token punctuation">;</span>
    
#end
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="entityvo-java-vm-1" tabindex="-1"><a class="header-anchor" href="#entityvo-java-vm-1" aria-hidden="true">#</a> entityVo.java.vm</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>##导入宏定义
$<span class="token operator">!</span><span class="token punctuation">{</span>define<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>
### 自定义全局变量 
$<span class="token operator">!</span><span class="token punctuation">{</span><span class="token class-name">My</span><span class="token operator">-</span>mayun<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##保存文件（宏定义）
#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;$!{volujing}&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;Vo.java&quot;</span><span class="token punctuation">)</span>

##包路径（宏定义）
#<span class="token function">setPackageSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;vo.$!{mokuai}&quot;</span><span class="token punctuation">)</span>

##自动导入包（全局变量）
$<span class="token operator">!</span><span class="token punctuation">{</span>autoImport<span class="token punctuation">.</span>vm<span class="token punctuation">}</span>

##表注释（宏定义）
#<span class="token function">tableComment</span><span class="token punctuation">(</span><span class="token string">&quot;表实体Vo类&quot;</span><span class="token punctuation">)</span>
 
<span class="token annotation punctuation">@Data</span>
<span class="token annotation punctuation">@ApiModel</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;$tableInfo.name Vo对象&quot;</span><span class="token punctuation">,</span> description <span class="token operator">=</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span><span class="token class-name">Vo</span> <span class="token keyword">extends</span> $<span class="token operator">!</span><span class="token punctuation">{</span>tableInfo<span class="token punctuation">.</span>name<span class="token punctuation">}</span>  <span class="token punctuation">{</span>

<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="避坑指南" tabindex="-1"><a class="header-anchor" href="#避坑指南" aria-hidden="true">#</a> 避坑指南</h3><h4 id="导包和组织路径" tabindex="-1"><a class="header-anchor" href="#导包和组织路径" aria-hidden="true">#</a> 导包和组织路径</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>##保存文件（宏定义）#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;生成有组织路径则加在这/文件位置&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;entity + 自定义后缀.java&quot;</span><span class="token punctuation">)</span>
#<span class="token function">save</span><span class="token punctuation">(</span><span class="token string">&quot;\entity\$!{Mymodule.vm}&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;.java&quot;</span><span class="token punctuation">)</span>

##包路径（宏定义）
#<span class="token function">setPackageSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;entity.$!{Mymodule.vm}&quot;</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230512173520104.png" alt="image-20230512173520104"></p></div></div><footer class="page-meta"><!----><div class="meta-item last-updated"><span class="xicon-container left meta-item-label"><!--[--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="xicon-icon" style="width:20px;height:20px;font-size:20px;color:inherit;"><path d="M26 4h-4V2h-2v2h-8V2h-2v2H6c-1.1 0-2 .9-2 2v20c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 22H6V12h20v14zm0-16H6V6h4v2h2V6h8v2h2V6h4v4z" fill="currentColor"></path></svg><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Last Updated 2023-07-19 09:58:39<!--]--></span></span></div></footer><nav class="page-nav"><p class="hasPrev inner"><span class="page-nav-item prev"> ← Java 开发的工具</span><!----></p></nav><!----></main><!--]--><div class="page-catalog-container"><h5 class="tip">文章层级目录</h5><ul><!--[--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#mybatis-代码生成器" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Mybatis - 代码生成器"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Mybatis - 代码生成器<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#pom-xml-生成器插件配置" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="pom.xml 生成器插件配置"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->pom.xml 生成器插件配置<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#generatorconfig-xml-配置" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="generatorConfig.xml  配置"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->generatorConfig.xml  配置<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#运行自动生成" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="运行自动生成"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->运行自动生成<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#mybatis-plus-代码生成器" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Mybatis-plus 代码生成器"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Mybatis-plus 代码生成器<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#添加依赖" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="添加依赖"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->添加依赖<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#添加-模板引擎" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="添加 模板引擎"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->添加 模板引擎<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#三层-代码生成器" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="三层 代码生成器"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->三层 代码生成器<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#自定义位置-代码生成器" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="自定义位置 代码生成器"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->自定义位置 代码生成器<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#mayun-代码生成器" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="MaYun 代码生成器"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->MaYun 代码生成器<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#easycode-代码生成器" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="EasyCode 代码生成器"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->EasyCode 代码生成器<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#下载插件" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="下载插件"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->下载插件<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#生成代码" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="生成代码"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->生成代码<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#自定义模板文件" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="自定义模板文件"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->自定义模板文件<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#自定义模板语法" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="自定义模板语法"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->自定义模板语法<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#mybatisplus-通用模板" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="MyBatisPlus 通用模板"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->MyBatisPlus 通用模板<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#自定义位置-生成模板" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="自定义位置 生成模板"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->自定义位置 生成模板<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/DmShengChen.html#避坑指南" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="避坑指南"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->避坑指南<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--]--></ul></div></div></div></div><!----><!----><!--]--></div>
    <script type="module" src="/assets/app-8a43a0f0.js" defer></script>
  </body>
</html>
